Metadata-Version: 2.5
Name: DiscreteVRP
Version: 0.1.5
Summary: An easy Python package for learning Discrete Mathematics, including Counting, Number Theory, and Graph Theory.
Project-URL: Homepage, https://github.com/Veerapat2549/Discrete_Veerapat
Project-URL: Documentation, https://github.com/Veerapat2549/Discrete_Veerapat#readme
Project-URL: Repository, https://github.com/Veerapat2549/Discrete_Veerapat.git
Project-URL: Bug Tracker, https://github.com/Veerapat2549/Discrete_Veerapat/issues
Author-email: Veerapat Chotikorn <p0636186013@gmail.com>
License: MIT
License-File: LICENSE
Keywords: counting,discrete-mathematics,education,graph-theory,number-theory
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.8
Requires-Dist: matplotlib>=3.5
Requires-Dist: networkx>=2.8
Requires-Dist: numpy>=1.21
Requires-Dist: pandas>=1.3
Requires-Dist: sympy>=1.9
Description-Content-Type: text/markdown

# Discrete Veerapat

**DiscreteVRP เวอร์ชัน 0.1.5** คือ Python package สำหรับฝึกเขียนโปรแกรมและเรียนรู้คณิตศาสตร์ดีสครีต (Discrete Mathematics) ในระดับเบื้องต้น เหมาะสำหรับนักศึกษาที่กำลังเริ่มเรียน Python

Package นี้มี 3 โมดูลหลัก:
- `counting` สำหรับหลักการนับ โครงสร้างข้อมูล และ recursion
- `number_theory` สำหรับทฤษฎีจำนวน, SymPy และ OOP เบื้องต้น
- `graph_theory` สำหรับทฤษฎีกราฟ โดยใช้ NetworkX, NumPy, Pandas และ Matplotlib

## การติดตั้ง

ติดตั้งจากโฟลเดอร์ package:

```bash
pip install .
```

หรือติดตั้งแบบแก้ไขโค้ดได้ทันทีระหว่างพัฒนา:

```bash
pip install -e .
```

## การเริ่มต้นใช้งาน

```python
import DiscreteVRP as dv

print(dv.__version__)  # 0.1.5
```

## 1. Counting Module

โมดูล `counting` ใช้สำหรับแฟกทอเรียล การเรียงสับเปลี่ยน การจัดหมู่ และหลักการนับพื้นฐาน

```python
import DiscreteVRP as dv

print(dv.factorial(5))  # 120
print(dv.permutation(5, 2))  # 20
print(dv.combination(5, 2))  # 10

print(dv.stars_and_bars(5, 3))  # 21
print(dv.stars_and_bars_at_least_one(5, 3))  # 6

print(dv.floor_function(3.7))  # 3
print(dv.ceiling_function(3.2))  # 4

print(dv.inclusion_exclusion_2(10, 15, 3))  # 22
print(dv.pigeonhole_principle(10, 3))
# At least 1 hole has 4 pigeons
```

### Recursive Function และ Memoization

```python
import DiscreteVRP as dv

print(dv.fibonacci(10))  # 55
```

`factorial()` และ `fibonacci()` ใช้ recursive function โดยใช้ memoization เพื่อเก็บค่าที่เคยคำนวณแล้ว

### String, Set และ Dictionary

```python
import DiscreteVRP as dv

print(dv.count_unique_permutations("AAB"))  # 3

print(dv.word_frequency("python is fun python"))
# {'python': 2, 'is': 1, 'fun': 1}
```

### Variable-length Arguments

```python
import DiscreteVRP as dv

print(dv.sum_numbers(1, 2, 3, 4, 5))  # 15
```

## 2. Number Theory Module

โมดูล `number_theory` ใช้สำหรับจำนวนเฉพาะ ห.ร.ม. ค.ร.น. Euclidean Algorithm และเลขมอดูลาร์

```python
import DiscreteVRP as dv

print(dv.is_even(4))  # True
print(dv.is_odd(7))  # True
print(dv.is_prime(29))  # True
print(dv.is_composite(10))  # True

print(dv.division_algorithm(70, 15))
# 70 = 4(15) + 10

print(dv.gcd(48, 18))  # 6
print(dv.lcm(12, 18))  # 36
```

### Euclidean Algorithm, Set และ SymPy

```python
import DiscreteVRP as dv

dv.euclidean_algorithm_steps(48, 18)

steps, result = dv.euclidean_algorithm_set(48, 18)
print(steps)
print(result)  # 6

print(dv.euclidean_algorithm_pretty(48, 18))
```

`euclidean_algorithm_set()` แสดงตัวอย่างการใช้ `set` ส่วน `euclidean_algorithm_pretty()` ใช้ SymPy เพื่อจัดรูปแบบสมการให้อ่านง่าย

### Extended Euclidean Algorithm, Modular Inverse และ CRT

```python
import DiscreteVRP as dv

print(dv.extended_gcd(17, 43))
print(dv.modular_inverse(3, 7))  # 5

print(dv.chinese_remainder_theorem([2, 3, 2], [3, 5, 7]))
# 23
```

### OOP, Magic Methods และ Inheritance

```python
import DiscreteVRP as dv

result = dv.MathResult("GCD", dv.gcd(48, 18))

print(result)       # GCD: 6
print(repr(result)) # MathResult(topic='GCD', value=6)
```

`MathResult` มี `__str__()` และ `__repr__()` เป็นตัวอย่าง magic methods

## 3. Graph Theory Module

โมดูล `graph_theory` ใช้ NetworkX สำหรับสร้างและวิเคราะห์กราฟ ใช้ Matplotlib สำหรับวาดกราฟ ใช้ NumPy สำหรับ adjacency matrix และใช้ Pandas สำหรับตาราง edge list

### สร้างและวาดกราฟ

```python
import DiscreteVRP as dv

graph = dv.create_graph([
    ("A", "B"),
    ("A", "C"),
    ("B", "C"),
    ("C", "D"),
])

dv.draw_graph(graph, title="My First Graph")
```

### Connected Components และ NumPy Matrix

```python
import DiscreteVRP as dv

graph = dv.create_graph([
    ("A", "B"),
    ("B", "C"),
    ("D", "E"),
])

print(dv.is_connected(graph))  # False
print(dv.connected_components(graph))

matrix = dv.adjacency_matrix(graph, ["A", "B", "C", "D", "E"])
print(matrix)
```

### Pandas และ File I/O

```python
import DiscreteVRP as dv

edges = [
    ("A", "B", 4),
    ("B", "C", 2),
]

print(dv.edges_to_dataframe(edges))

dv.save_edges_to_file(edges, "edges.txt")
graph = dv.load_graph_from_file("edges.txt", weighted=True)

print(list(graph.edges(data=True)))
```

### Euler Trail, Tree และ Shortest Path

```python
import DiscreteVRP as dv

triangle = dv.create_graph([
    ("A", "B"),
    ("B", "C"),
    ("C", "A"),
])

print(dv.has_euler_path(triangle))  # True
print(dv.has_euler_circuit(triangle))  # True
print(dv.euler_path(triangle))
```

```python
import DiscreteVRP as dv

weighted_graph = dv.create_graph(
    [
        ("A", "B", 4),
        ("A", "C", 2),
        ("B", "C", 1),
        ("B", "D", 5),
        ("C", "D", 8),
    ],
    weighted=True,
)

path, distance = dv.shortest_path(weighted_graph, "A", "D")

print(path)      # ['A', 'C', 'B', 'D']
print(distance)  # 8
```

### Minimum Spanning Tree และ Algorithm Comparison

```python
import DiscreteVRP as dv

mst = dv.minimum_spanning_tree(weighted_graph, algorithm="kruskal")
print(list(mst.edges(data=True)))

print(dv.compare_mst_algorithms(weighted_graph))
```

`compare_mst_algorithms()` เปรียบเทียบเวลาในการทำงานของ Kruskal's Algorithm และ Prim's Algorithm

## การทดสอบ

รันโค้ดทดสอบในแต่ละโมดูล:

```bash
python -m DiscreteVRP.counting
python -m DiscreteVRP.number_theory
python -m DiscreteVRP.graph_theory
```

รัน automated tests:

```bash
python -m unittest discover -s tests
```

## การ Build และเผยแพร่บน PyPI

ติดตั้งเครื่องมือ:

```bash
pip install build twine
```

สร้างไฟล์ distribution:

```bash
python -m build
```

ตรวจสอบไฟล์:

```bash
twine check dist/*
```

อัปโหลดไปยัง PyPI:

```bash
twine upload dist/*
```

## หมายเหตุ

- Package นี้เน้นโค้ดสั้น อ่านง่าย และเหมาะกับการเรียนรู้
- `adjacency_matrix()` คืนค่าเป็น `numpy.ndarray`
- Graph Theory เหมาะสำหรับการทดลองกับกราฟขนาดเล็ก
- ไม่มี PARI/cypari2 จึงสามารถติดตั้งบน Windows ได้ง่ายขึ้น