Graphinate 0.0.8__tar.gz → 0.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {graphinate-0.0.8 → graphinate-0.0.9}/PKG-INFO +67 -71
  2. {graphinate-0.0.8 → graphinate-0.0.9}/README.md +66 -69
  3. graphinate-0.0.9/docs/acknowledgements.md +26 -0
  4. graphinate-0.0.9/docs/examples.md +18 -0
  5. graphinate-0.0.9/docs/gallery.md +13 -0
  6. graphinate-0.0.9/docs/index.md +13 -0
  7. graphinate-0.0.9/docs/install.md +15 -0
  8. graphinate-0.0.9/docs/intro.md +63 -0
  9. graphinate-0.0.9/docs/start.md +37 -0
  10. graphinate-0.0.9/docs/usage.md +19 -0
  11. {graphinate-0.0.8 → graphinate-0.0.9}/examples/code/python_ast.py +2 -2
  12. {graphinate-0.0.8 → graphinate-0.0.9}/examples/github/followers.py +2 -3
  13. {graphinate-0.0.8 → graphinate-0.0.9}/examples/github/repositories.py +4 -5
  14. {graphinate-0.0.8 → graphinate-0.0.9}/examples/math/graph_atlas.py +1 -1
  15. {graphinate-0.0.8 → graphinate-0.0.9}/examples/math/hailstone.py +2 -2
  16. graphinate-0.0.9/examples/math/polygonal_graph.py +36 -0
  17. {graphinate-0.0.8 → graphinate-0.0.9}/examples/text/nlp_graph.py +1 -2
  18. {graphinate-0.0.8 → graphinate-0.0.9}/examples/web/web_graph.py +2 -2
  19. {graphinate-0.0.8 → graphinate-0.0.9}/mkdocs.yml +7 -1
  20. {graphinate-0.0.8 → graphinate-0.0.9}/pyproject.toml +2 -3
  21. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/__init__.py +1 -1
  22. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/cli.py +3 -5
  23. {graphinate-0.0.8/src/graphinate/materialize → graphinate-0.0.9/src/graphinate/materializers}/__init__.py +13 -7
  24. {graphinate-0.0.8/src/graphinate/materialize → graphinate-0.0.9/src/graphinate/materializers}/matplotlib.py +7 -7
  25. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/modeling.py +2 -2
  26. graphinate-0.0.8/docs/index.md +0 -7
  27. graphinate-0.0.8/docs/install.md +0 -9
  28. graphinate-0.0.8/docs/usage.md +0 -10
  29. {graphinate-0.0.8 → graphinate-0.0.9}/.github/workflows/codeql.yml +0 -0
  30. {graphinate-0.0.8 → graphinate-0.0.9}/.github/workflows/publish.yml +0 -0
  31. {graphinate-0.0.8 → graphinate-0.0.9}/.github/workflows/test-python-beta.yml +0 -0
  32. {graphinate-0.0.8 → graphinate-0.0.9}/.github/workflows/test.yml +0 -0
  33. {graphinate-0.0.8 → graphinate-0.0.9}/.gitignore +0 -0
  34. {graphinate-0.0.8 → graphinate-0.0.9}/LICENSE +0 -0
  35. {graphinate-0.0.8 → graphinate-0.0.9}/docs/assets/images/network_graph.png +0 -0
  36. {graphinate-0.0.8 → graphinate-0.0.9}/examples/code/call_graph.py +0 -0
  37. {graphinate-0.0.8 → graphinate-0.0.9}/examples/code/requirements.txt +0 -0
  38. {graphinate-0.0.8 → graphinate-0.0.9}/examples/ethernet/traceroute.py +0 -0
  39. {graphinate-0.0.8 → graphinate-0.0.9}/examples/genric_graph.graphql +0 -0
  40. {graphinate-0.0.8 → graphinate-0.0.9}/examples/github/_client.py +0 -0
  41. {graphinate-0.0.8 → graphinate-0.0.9}/examples/github/followers.graphql +0 -0
  42. {graphinate-0.0.8 → graphinate-0.0.9}/examples/github/graphql.config.yml +0 -0
  43. {graphinate-0.0.8 → graphinate-0.0.9}/examples/github/repositories.graphql +0 -0
  44. {graphinate-0.0.8 → graphinate-0.0.9}/examples/graphql.config.yml +0 -0
  45. {graphinate-0.0.8 → graphinate-0.0.9}/examples/web/requirements.txt +0 -0
  46. {graphinate-0.0.8 → graphinate-0.0.9}/playground/grap_genus.py +0 -0
  47. {graphinate-0.0.8 → graphinate-0.0.9}/playground/house_of_graphs.py +0 -0
  48. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/__main__.py +0 -0
  49. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/builders.py +0 -0
  50. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/color.py +0 -0
  51. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/__init__.py +0 -0
  52. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/starlette/__init__.py +0 -0
  53. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/starlette/views.py +0 -0
  54. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/__init__.py +0 -0
  55. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/graphiql/__init__.py +0 -0
  56. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/graphiql/index.html +0 -0
  57. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/static/images/network_graph.png +0 -0
  58. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/viewer/__init__.py +0 -0
  59. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/viewer/index.html +0 -0
  60. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/voyager/__init__.py +0 -0
  61. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/server/web/voyager/index.html +0 -0
  62. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/tools/__init__.py +0 -0
  63. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/tools/fs.py +0 -0
  64. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/tools/gui.py +0 -0
  65. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/tools/importer.py +0 -0
  66. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/tools/mutators.py +0 -0
  67. {graphinate-0.0.8 → graphinate-0.0.9}/src/graphinate/typing.py +0 -0
  68. {graphinate-0.0.8 → graphinate-0.0.9}/tests/conftest.py +0 -0
  69. {graphinate-0.0.8 → graphinate-0.0.9}/tests/graphinate/test_builders.py +0 -0
  70. {graphinate-0.0.8 → graphinate-0.0.9}/tests/graphinate/test_modeling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Graphinate
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: Graphinate. Data to Graphs.
5
5
  Project-URL: Homepage, https://github.com/erivlis/graphinate
6
6
  Project-URL: Documentation, https://github.com/erivlis/graphinate#README.md
@@ -35,7 +35,6 @@ Requires-Dist: strawberry-graphql[asgi,opentelemetry]
35
35
  Provides-Extra: dev
36
36
  Requires-Dist: ruff; extra == 'dev'
37
37
  Provides-Extra: plot
38
- Requires-Dist: matplotlib; extra == 'plot'
39
38
  Requires-Dist: scipy; extra == 'plot'
40
39
  Provides-Extra: server
41
40
  Requires-Dist: starlette-prometheus; extra == 'server'
@@ -47,9 +46,10 @@ Description-Content-Type: text/markdown
47
46
 
48
47
  # Graphinate. Data to Graphs.
49
48
 
50
- ## ⚠️ **Under Development!** ⚠️
51
-
52
- This library is alpha-quality
49
+ > [!WARNING]
50
+ > **UNDER DEVELOPMENT**
51
+ >
52
+ > **This library is alpha-quality**
53
53
 
54
54
  ![PyPI](https://img.shields.io/pypi/v/graphinate)
55
55
  ![PyPI - Status](https://img.shields.io/pypi/status/graphinate)
@@ -63,98 +63,70 @@ This library is alpha-quality
63
63
  [![Tests](https://github.com/erivlis/graphinate/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
64
64
  [![Publish](https://github.com/erivlis/graphinate/actions/workflows/publish.yml/badge.svg)](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
65
65
 
66
- ## Install
67
-
68
- Graphinate is available on PyPI:
69
-
70
- ```shell
71
- python -m pip install graphinate
72
- ```
73
-
74
- Graphinate officially supports Python 3.9+.
75
-
76
66
  ## Introduction
77
67
 
78
68
  ### What is Graphinate?
79
69
 
80
- Graphinate aims to simplify the generation of Graph data structures from sources of data.
81
- It utilizes and build upon [NetworkX](https://networkx.org/)
70
+ Graphinate is a library that aims to simplify the generation of Graph Data Structures from Data Sources.
82
71
 
83
- ### What is a Graph?
72
+ It utilizes and builds upon the excellent [**_NetworkX_**](https://networkx.org/) library.
84
73
 
85
- > In a mathematician's terminology, a graph is a collection of points and lines connecting some (possibly empty) subset
86
- > of them. The points of a graph are most commonly known as graph vertices, but may also be called "nodes" or simply "
87
- > points." Similarly, the lines connecting the vertices of a graph are most commonly known as graph edges, but may also
88
- > be
89
- > called "arcs" or "lines."
90
- >
91
- > — [https://mathworld.wolfram.com/Graph.html](https://mathworld.wolfram.com/Graph.html)
74
+ In addition, it has several interfaces for ease of use:
92
75
 
93
- ### What is Data?
76
+ - CLI (using [**_Click_**](https://palletsprojects.com/p/click/)),
77
+ - GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
94
78
 
95
- > ...data is a collection of discrete or continuous values that convey information, describing the quantity, quality,
96
- > fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted
97
- > formally.
98
- >
99
- > — [https://en.wikipedia.org/wiki/Data](https://en.wikipedia.org/wiki/Data)
79
+ [//]: # (- TUI (using [**_Textual_**](https://textual.textualize.io/)) **⚠️Not available yet⚠️**)
100
80
 
101
- ### Defining a Graph
81
+ ## Install
102
82
 
103
- One can define Graphs in two general ways:
83
+ Graphinate is available on PyPI:
104
84
 
105
- #### Edge first
85
+ ```shell
86
+ pip install graphinate
87
+ ```
106
88
 
107
- Generate a Graph by supplying a list of edges. The simplest definition of an edge will be a tuple of 2 values. Each
108
- value represent a node (or vertex) in the graph. Additional attributes may be also added to the edge definition to
109
- signify additional meaning.
89
+ To install with server support
110
90
 
111
- In this case one defines the **edges explicitly** and the **nodes implicitly**.
91
+ ```shell
92
+ pip install graphinate[server]
93
+ ```
112
94
 
113
- Such graph is focused more on the _relationships_ or the _structure_ of the Graph than on the nodes themselves.
95
+ Graphinate officially supports Python 3.9+.
114
96
 
115
- #### Node first
97
+ ## Quick Start
116
98
 
117
- Alternatively, one can first add nodes (vertices) to a graph without defining edges. Additional attributes may be added
118
- to the node definition to signify additional meaning. Later on edge definitions are added to generate the relationships
119
- between the nodes.
99
+ ### `GraphModel`
120
100
 
121
- In this case **both nodes and the edges** are defines **explicitly**.
101
+ Graphinate defines the `GraphModel` Class which can be used to declaratively register _Edge_ and/or _Node_ data
102
+ supplier functions by using decorators.
122
103
 
123
- Such a graph has focus first on the nodes and later on the relationship between them.
104
+ ### `materialize`
124
105
 
125
- ## Gallery
106
+ Graphinate supplies a `materialize` function to output the `GraphModel`.
126
107
 
127
- ![d3_graph_ast](https://github.com/erivlis/graphinate/assets/9897520/9e7e1ed2-3a5c-41fe-8c5f-999da4b741ff)
128
- ![repo_graph](https://github.com/erivlis/graphinate/assets/9897520/9c044bbe-1f21-41b8-b879-95b8362ad48d)
129
- ![AST 3D Force animation](https://github.com/erivlis/graphinate/assets/9897520/2e9a53b1-5686-4683-a0e4-fbffa850a27b)
108
+ ### Example
130
109
 
131
- ## Examples
110
+ ```python
111
+ import graphinate
132
112
 
133
- - [ ] Code
134
- - [ ] Call Graph
135
- - [x] Python AST
136
- - [x] GitHub
137
- - [x] Repository
138
- - [x] Followers
139
- - [ ] Ethernet
140
- - [ ] Traceroute
141
- - [ ] Math
142
- - [x] Graph Atlas
143
- - [ ] Hailstone
144
- - [ ] Text
145
- - [ ] NLP
146
- - [ ] Web
147
- - [ ] Web Graph
113
+ N: int = 8
148
114
 
149
- ## Guide
115
+ # Define GraphModel
116
+ graph_model = graphinate.GraphModel(name="Octagonal Graph")
150
117
 
151
- ### By Convention
152
118
 
153
- https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/followers.py#L1
119
+ # Register edges supplier function
120
+ @graph_model.edge()
121
+ def edge():
122
+ for i in range(N):
123
+ yield {'source': i, 'target': i + 1}
124
+ yield {'source': N, 'target': 0}
154
125
 
155
- ### By Configuration
156
126
 
157
- https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/repositories.py#L1
127
+ # Materialize the GraphModel
128
+ graphinate.materialize(graph_model)
129
+ ```
158
130
 
159
131
  ## CLI
160
132
 
@@ -190,6 +162,24 @@ Options:
190
162
  --help Show this message and exit.
191
163
  ```
192
164
 
165
+ ## TUI
166
+
167
+ UNDER DEVELOPMENT
168
+
169
+ ## Gallery
170
+
171
+ ### Python AST
172
+
173
+ ![d3_graph_ast](https://github.com/erivlis/graphinate/assets/9897520/9e7e1ed2-3a5c-41fe-8c5f-999da4b741ff)
174
+
175
+ ### GitHub Repository
176
+
177
+ ![repo_graph](https://github.com/erivlis/graphinate/assets/9897520/9c044bbe-1f21-41b8-b879-95b8362ad48d)
178
+
179
+ ### Python AST - 3D Force-Directed Animation
180
+
181
+ ![AST 3D Force animation](https://github.com/erivlis/graphinate/assets/9897520/2e9a53b1-5686-4683-a0e4-fbffa850a27b)
182
+
193
183
  ## Development
194
184
 
195
185
  ### Lint
@@ -220,13 +210,19 @@ python -m build
220
210
 
221
211
  ### Dependencies
222
212
 
223
- <a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
213
+ #### Python
214
+
224
215
  <a href="https://palletsprojects.com/p/click/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://click.palletsprojects.com/en/7.x/_images/click-logo.png" alt="Click Logo."></a>
225
216
  <a href="https://github.com/Delgan/loguru"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://raw.githubusercontent.com/Delgan/loguru/master/docs/_static/img/logo.png" alt="Loguru Logo."></a>
226
217
  <a href="https://matplotlib.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://matplotlib.org/_static/logo_dark.svg" alt="matplotlib Logo."></a>
227
218
  <a href="https://networkx.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://networkx.org/_static/networkx_logo.svg" alt="NetworkX Logo."></a>
228
219
  <a href="https://strawberry.rocks/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/strawberry-graphql/strawberry/raw/main/.github/logo.png" alt="Strawberry GraphQL Logo."></a>
229
220
 
221
+ #### Javascript and HTML
222
+
223
+ <a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
224
+ <a href="https://github.com/graphql-kit/graphql-voyager"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/graphql-kit/graphql-voyager/raw/main/docs/cover.png" alt="Graphql Voyager Logo."></a>
225
+
230
226
  ### Dev Tools
231
227
 
232
228
  <a href="https://hatch.pypa.io/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://hatch.pypa.io/latest/assets/images/logo.svg" alt="Hatch logo."></a>
@@ -1,8 +1,9 @@
1
1
  # Graphinate. Data to Graphs.
2
2
 
3
- ## ⚠️ **Under Development!** ⚠️
4
-
5
- This library is alpha-quality
3
+ > [!WARNING]
4
+ > **UNDER DEVELOPMENT**
5
+ >
6
+ > **This library is alpha-quality**
6
7
 
7
8
  ![PyPI](https://img.shields.io/pypi/v/graphinate)
8
9
  ![PyPI - Status](https://img.shields.io/pypi/status/graphinate)
@@ -16,98 +17,70 @@ This library is alpha-quality
16
17
  [![Tests](https://github.com/erivlis/graphinate/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
17
18
  [![Publish](https://github.com/erivlis/graphinate/actions/workflows/publish.yml/badge.svg)](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
18
19
 
19
- ## Install
20
-
21
- Graphinate is available on PyPI:
22
-
23
- ```shell
24
- python -m pip install graphinate
25
- ```
26
-
27
- Graphinate officially supports Python 3.9+.
28
-
29
20
  ## Introduction
30
21
 
31
22
  ### What is Graphinate?
32
23
 
33
- Graphinate aims to simplify the generation of Graph data structures from sources of data.
34
- It utilizes and build upon [NetworkX](https://networkx.org/)
24
+ Graphinate is a library that aims to simplify the generation of Graph Data Structures from Data Sources.
35
25
 
36
- ### What is a Graph?
26
+ It utilizes and builds upon the excellent [**_NetworkX_**](https://networkx.org/) library.
37
27
 
38
- > In a mathematician's terminology, a graph is a collection of points and lines connecting some (possibly empty) subset
39
- > of them. The points of a graph are most commonly known as graph vertices, but may also be called "nodes" or simply "
40
- > points." Similarly, the lines connecting the vertices of a graph are most commonly known as graph edges, but may also
41
- > be
42
- > called "arcs" or "lines."
43
- >
44
- > &mdash; [https://mathworld.wolfram.com/Graph.html](https://mathworld.wolfram.com/Graph.html)
28
+ In addition, it has several interfaces for ease of use:
45
29
 
46
- ### What is Data?
30
+ - CLI (using [**_Click_**](https://palletsprojects.com/p/click/)),
31
+ - GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
47
32
 
48
- > ...data is a collection of discrete or continuous values that convey information, describing the quantity, quality,
49
- > fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted
50
- > formally.
51
- >
52
- > &mdash; [https://en.wikipedia.org/wiki/Data](https://en.wikipedia.org/wiki/Data)
33
+ [//]: # (- TUI &#40;using [**_Textual_**]&#40;https://textual.textualize.io/&#41;&#41; **⚠️Not available yet⚠️**)
53
34
 
54
- ### Defining a Graph
35
+ ## Install
55
36
 
56
- One can define Graphs in two general ways:
37
+ Graphinate is available on PyPI:
57
38
 
58
- #### Edge first
39
+ ```shell
40
+ pip install graphinate
41
+ ```
59
42
 
60
- Generate a Graph by supplying a list of edges. The simplest definition of an edge will be a tuple of 2 values. Each
61
- value represent a node (or vertex) in the graph. Additional attributes may be also added to the edge definition to
62
- signify additional meaning.
43
+ To install with server support
63
44
 
64
- In this case one defines the **edges explicitly** and the **nodes implicitly**.
45
+ ```shell
46
+ pip install graphinate[server]
47
+ ```
65
48
 
66
- Such graph is focused more on the _relationships_ or the _structure_ of the Graph than on the nodes themselves.
49
+ Graphinate officially supports Python 3.9+.
67
50
 
68
- #### Node first
51
+ ## Quick Start
69
52
 
70
- Alternatively, one can first add nodes (vertices) to a graph without defining edges. Additional attributes may be added
71
- to the node definition to signify additional meaning. Later on edge definitions are added to generate the relationships
72
- between the nodes.
53
+ ### `GraphModel`
73
54
 
74
- In this case **both nodes and the edges** are defines **explicitly**.
55
+ Graphinate defines the `GraphModel` Class which can be used to declaratively register _Edge_ and/or _Node_ data
56
+ supplier functions by using decorators.
75
57
 
76
- Such a graph has focus first on the nodes and later on the relationship between them.
58
+ ### `materialize`
77
59
 
78
- ## Gallery
60
+ Graphinate supplies a `materialize` function to output the `GraphModel`.
79
61
 
80
- ![d3_graph_ast](https://github.com/erivlis/graphinate/assets/9897520/9e7e1ed2-3a5c-41fe-8c5f-999da4b741ff)
81
- ![repo_graph](https://github.com/erivlis/graphinate/assets/9897520/9c044bbe-1f21-41b8-b879-95b8362ad48d)
82
- ![AST 3D Force animation](https://github.com/erivlis/graphinate/assets/9897520/2e9a53b1-5686-4683-a0e4-fbffa850a27b)
62
+ ### Example
83
63
 
84
- ## Examples
64
+ ```python
65
+ import graphinate
85
66
 
86
- - [ ] Code
87
- - [ ] Call Graph
88
- - [x] Python AST
89
- - [x] GitHub
90
- - [x] Repository
91
- - [x] Followers
92
- - [ ] Ethernet
93
- - [ ] Traceroute
94
- - [ ] Math
95
- - [x] Graph Atlas
96
- - [ ] Hailstone
97
- - [ ] Text
98
- - [ ] NLP
99
- - [ ] Web
100
- - [ ] Web Graph
67
+ N: int = 8
101
68
 
102
- ## Guide
69
+ # Define GraphModel
70
+ graph_model = graphinate.GraphModel(name="Octagonal Graph")
103
71
 
104
- ### By Convention
105
72
 
106
- https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/followers.py#L1
73
+ # Register edges supplier function
74
+ @graph_model.edge()
75
+ def edge():
76
+ for i in range(N):
77
+ yield {'source': i, 'target': i + 1}
78
+ yield {'source': N, 'target': 0}
107
79
 
108
- ### By Configuration
109
80
 
110
- https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/repositories.py#L1
81
+ # Materialize the GraphModel
82
+ graphinate.materialize(graph_model)
83
+ ```
111
84
 
112
85
  ## CLI
113
86
 
@@ -143,6 +116,24 @@ Options:
143
116
  --help Show this message and exit.
144
117
  ```
145
118
 
119
+ ## TUI
120
+
121
+ UNDER DEVELOPMENT
122
+
123
+ ## Gallery
124
+
125
+ ### Python AST
126
+
127
+ ![d3_graph_ast](https://github.com/erivlis/graphinate/assets/9897520/9e7e1ed2-3a5c-41fe-8c5f-999da4b741ff)
128
+
129
+ ### GitHub Repository
130
+
131
+ ![repo_graph](https://github.com/erivlis/graphinate/assets/9897520/9c044bbe-1f21-41b8-b879-95b8362ad48d)
132
+
133
+ ### Python AST - 3D Force-Directed Animation
134
+
135
+ ![AST 3D Force animation](https://github.com/erivlis/graphinate/assets/9897520/2e9a53b1-5686-4683-a0e4-fbffa850a27b)
136
+
146
137
  ## Development
147
138
 
148
139
  ### Lint
@@ -173,13 +164,19 @@ python -m build
173
164
 
174
165
  ### Dependencies
175
166
 
176
- <a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
167
+ #### Python
168
+
177
169
  <a href="https://palletsprojects.com/p/click/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://click.palletsprojects.com/en/7.x/_images/click-logo.png" alt="Click Logo."></a>
178
170
  <a href="https://github.com/Delgan/loguru"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://raw.githubusercontent.com/Delgan/loguru/master/docs/_static/img/logo.png" alt="Loguru Logo."></a>
179
171
  <a href="https://matplotlib.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://matplotlib.org/_static/logo_dark.svg" alt="matplotlib Logo."></a>
180
172
  <a href="https://networkx.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://networkx.org/_static/networkx_logo.svg" alt="NetworkX Logo."></a>
181
173
  <a href="https://strawberry.rocks/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/strawberry-graphql/strawberry/raw/main/.github/logo.png" alt="Strawberry GraphQL Logo."></a>
182
174
 
175
+ #### Javascript and HTML
176
+
177
+ <a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
178
+ <a href="https://github.com/graphql-kit/graphql-voyager"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/graphql-kit/graphql-voyager/raw/main/docs/cover.png" alt="Graphql Voyager Logo."></a>
179
+
183
180
  ### Dev Tools
184
181
 
185
182
  <a href="https://hatch.pypa.io/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://hatch.pypa.io/latest/assets/images/logo.svg" alt="Hatch logo."></a>
@@ -0,0 +1,26 @@
1
+ # Acknowledgements
2
+
3
+ ## Dependencies
4
+
5
+ ### Python
6
+
7
+ <a href="https://palletsprojects.com/p/click/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://click.palletsprojects.com/en/7.x/_images/click-logo.png" alt="Click Logo."></a>
8
+ <a href="https://github.com/Delgan/loguru"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://raw.githubusercontent.com/Delgan/loguru/master/docs/_static/img/logo.png" alt="Loguru Logo."></a>
9
+ <a href="https://matplotlib.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://matplotlib.org/_static/logo_dark.svg" alt="matplotlib Logo."></a>
10
+ <a href="https://networkx.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://networkx.org/_static/networkx_logo.svg" alt="NetworkX Logo."></a>
11
+ <a href="https://strawberry.rocks/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/strawberry-graphql/strawberry/raw/main/.github/logo.png" alt="Strawberry GraphQL Logo."></a>
12
+
13
+ ### Javascript and HTML
14
+
15
+ <a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
16
+ <a href="https://github.com/graphql-kit/graphql-voyager"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/graphql-kit/graphql-voyager/raw/main/docs/cover.png" alt="Graphql Voyager Logo."></a>
17
+
18
+ ## Dev Tools
19
+
20
+ <a href="https://hatch.pypa.io/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://hatch.pypa.io/latest/assets/images/logo.svg" alt="Hatch logo."></a>
21
+ <a href="https://pytest.org"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://docs.pytest.org/en/7.4.x/_static/pytest_logo_curves.svg" alt="pytest logo."></a>
22
+ <a href="https://astral.sh/ruff"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://astralcms.wpengine.com/wp-content/uploads/2023/03/Ruff-Logo.svg" alt="Ruff logo."></a>
23
+
24
+ ## IDE
25
+
26
+ <a href="https://www.jetbrains.com/pycharm/"><img height="50" style="background: linear-gradient(-45deg, #FCF84A, #3DEA62, #21D789);" src="https://resources.jetbrains.com/storage/products/company/brand/logos/PyCharm.png" alt="PyCharm logo."></a>
@@ -0,0 +1,18 @@
1
+ # Examples
2
+
3
+ - Code
4
+ - Call Graph
5
+ - Python AST
6
+ - GitHub
7
+ - Repository
8
+ - Followers
9
+ - Ethernet
10
+ - Traceroute
11
+ - Math
12
+ - Graph Atlas
13
+ - Hailstone
14
+ - Polygonal Graph
15
+ - Text
16
+ - NLP
17
+ - Web
18
+ - Web Graph
@@ -0,0 +1,13 @@
1
+ # Gallery
2
+
3
+ ## Python AST
4
+
5
+ ![d3_graph_ast](https://github.com/erivlis/graphinate/assets/9897520/9e7e1ed2-3a5c-41fe-8c5f-999da4b741ff)
6
+
7
+ ## GitHub Repository
8
+
9
+ ![repo_graph](https://github.com/erivlis/graphinate/assets/9897520/9c044bbe-1f21-41b8-b879-95b8362ad48d)
10
+
11
+ ## Python AST - 3D Force-Directed Animation
12
+
13
+ ![AST 3D Force animation](https://github.com/erivlis/graphinate/assets/9897520/2e9a53b1-5686-4683-a0e4-fbffa850a27b)
@@ -0,0 +1,13 @@
1
+ # Graphinate. Data to Graphs.
2
+
3
+ ![PyPI](https://img.shields.io/pypi/v/graphinate)
4
+ ![PyPI - Status](https://img.shields.io/pypi/status/graphinate)
5
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/graphinate)
6
+ ![GitHub](https://img.shields.io/github/license/erivlis/graphinate)
7
+ ![PyPI - Downloads](https://img.shields.io/pypi/dd/graphinate)
8
+ ![GitHub repo size](https://img.shields.io/github/repo-size/erivlis/graphinate)
9
+ [![Contributors](https://img.shields.io/github/contributors/erivlis/graphinate.svg)](https://github.com/erivlis/graphinate/graphs/contributors)
10
+ ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/erivlis/graphinate)
11
+
12
+ [![Tests](https://github.com/erivlis/graphinate/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
13
+ [![Publish](https://github.com/erivlis/graphinate/actions/workflows/publish.yml/badge.svg)](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
@@ -0,0 +1,15 @@
1
+ ## Install
2
+
3
+ Graphinate is available on PyPI:
4
+
5
+ ```shell
6
+ pip install graphinate
7
+ ```
8
+
9
+ To install with server support
10
+
11
+ ```shell
12
+ pip install graphinate[server]
13
+ ```
14
+
15
+ Graphinate officially supports Python 3.9+.
@@ -0,0 +1,63 @@
1
+ # Introduction
2
+
3
+ ## What is Graphinate?
4
+
5
+ Graphinate is a library that aims to simplify the generation of Graph Data Structures from Data Sources.
6
+
7
+ It utilizes and builds upon the excellent [**_NetworkX_**](https://networkx.org/) library.
8
+
9
+ In addition, it has several interfaces for ease of use:
10
+
11
+ - CLI (using [**_Click_**](https://palletsprojects.com/p/click/)),
12
+ - TUI (using [**_Textual_**](https://textual.textualize.io/)) **⚠️Not available yet⚠️**
13
+ - GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
14
+
15
+ ## What is a Graph?
16
+
17
+ “In a mathematician's terminology, a graph is a collection of points and lines connecting some (possibly empty) subset
18
+ of them. The points of a graph are most commonly known as graph vertices, but may also be called "nodes" or simply "
19
+ points." Similarly, the lines connecting the vertices of a graph are most commonly known as graph edges, but may also
20
+ be called "arcs" or "lines."”
21
+
22
+ &mdash; [https://mathworld.wolfram.com/Graph.html](https://mathworld.wolfram.com/Graph.html)
23
+
24
+ ## What is Data?
25
+
26
+ “...data is a collection of discrete or continuous values that convey information, describing the quantity, quality,
27
+ fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted
28
+ formally.”
29
+
30
+ &mdash; [https://en.wikipedia.org/wiki/Data](https://en.wikipedia.org/wiki/Data)
31
+
32
+ ## A Graph as Data Structure
33
+
34
+ A Graph is a very useful data structure. They are the simplest data structure that is more the just simple collection of
35
+ entities. As such they can be used to model all data sources that have structure.
36
+
37
+ Let's start with a simple use case, The Social Network Graph.
38
+
39
+ ## Defining a Graph
40
+
41
+ One can define a Graph in two general ways:
42
+
43
+ ### Edge first
44
+
45
+ Generate a Graph by supplying a list of edges. The simplest definition of an edge will be a tuple of 2 values. Each
46
+ value represent a node (or vertex) in the graph. Additional attributes may be also added to the edge definition to
47
+ signify additional meaning.
48
+
49
+ In this case one defines the **edges explicitly** and the **nodes implicitly**.
50
+
51
+ Such graph is focused more on the _relationships_ or the _structure_ of the Graph than on the nodes themselves.
52
+
53
+ ### Node first
54
+
55
+ Alternatively, one can first add nodes (vertices) to a graph without defining edges. Additional attributes may be added
56
+ to the node definition to signify additional meaning. Later on edge definitions are added to generate the relationships
57
+ between the nodes.
58
+
59
+ In this case **both nodes and the edges** are defines **explicitly**.
60
+
61
+ Such a graph has focus first on the nodes and later on the relationship between them.
62
+
63
+ ## Graphinate - Hydrate a Graph from a Data Source
@@ -0,0 +1,37 @@
1
+
2
+ ## Quick Start
3
+
4
+ Graphinate is designed to be used as library first and foremost. In addition, it has several interfaces for ease of
5
+ use: CLI, TUI (using [Textual]) and a GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
6
+
7
+ ### GraphModel
8
+
9
+ Graphinate defines the _**GraphModel**_ Class which can be used to declaratively register Edge and/or Node data
10
+ supplier functions by using decorators.
11
+
12
+ ### Materialize
13
+
14
+ Graphinate supplies quick materialize function to output the GraphModel.
15
+
16
+ ### Sample Code
17
+
18
+ ```python
19
+ import graphinate
20
+
21
+ # Define GraphModel
22
+ model = graphinate.GraphModel(name= "Octagonal Graph")
23
+
24
+ # Register edges supplier function
25
+ N: int = 8
26
+
27
+
28
+ @model.edge()
29
+ def edge():
30
+ for i in range(N):
31
+ yield {'source': i, 'target': i + 1}
32
+ yield {'source': N, 'target': 0}
33
+
34
+
35
+ # Materialize the GraphModel
36
+ graphinate.materialize(model)
37
+ ```
@@ -0,0 +1,19 @@
1
+ # Usage
2
+
3
+ ## Model
4
+
5
+ ## Build
6
+
7
+ ## Materialize
8
+
9
+
10
+
11
+
12
+
13
+ ### By Convention
14
+
15
+ https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/followers.py
16
+
17
+ ### By Configuration
18
+
19
+ https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/repositories.py
@@ -29,7 +29,7 @@ def _ast_edge(parsed_ast: AST):
29
29
 
30
30
 
31
31
  def ast_graph_model():
32
- graph_model = graphinate.GraphModel(name='AST')
32
+ graph_model = graphinate.GraphModel(name='AST Graph')
33
33
 
34
34
  root_ast_node = ast.parse(inspect.getsource(graphinate.builders.D3Builder))
35
35
 
@@ -58,4 +58,4 @@ def ast_graph_model():
58
58
 
59
59
  if __name__ == '__main__':
60
60
  ast_model = ast_graph_model()
61
- graphinate.materialize("AST Graph", ast_model)
61
+ graphinate.materialize(ast_model)
@@ -7,7 +7,7 @@ DEPTH = 0
7
7
 
8
8
 
9
9
  def followers_graph_model(max_depth: int = DEPTH):
10
- graph_model = graphinate.GraphModel(name='github-followers')
10
+ graph_model = graphinate.GraphModel(name='Github Followers Graph')
11
11
 
12
12
  def _followers(user_id: Optional[str] = None, depth: int = 0, **kwargs):
13
13
  user = github_user(user_id)
@@ -34,8 +34,7 @@ if __name__ == '__main__':
34
34
  }
35
35
 
36
36
  graphinate.materialize(
37
- title="Github Followers Graph",
38
- graph_model=followers_model,
37
+ model=followers_model,
39
38
  graph_type=graphinate.GraphType.DiGraph,
40
39
  default_node_attributes={'type': 'user'},
41
40
  **params
@@ -7,11 +7,11 @@ import pathlib
7
7
  from typing import Optional
8
8
 
9
9
  import graphinate
10
- from _client import github_user, github_repositories, github_commits, github_files
10
+ from _client import github_commits, github_files, github_repositories, github_user
11
11
 
12
12
 
13
13
  def repo_graph_model():
14
- graph_model = graphinate.GraphModel(name='github-repository')
14
+ graph_model = graphinate.GraphModel(name='GitHub Repository Graph')
15
15
 
16
16
  @graph_model.edge
17
17
  def github(user_id: Optional[str] = None,
@@ -60,8 +60,7 @@ def repo_graph_model():
60
60
  repository_id: Optional[str] = None,
61
61
  **kwargs):
62
62
  repos = github_repositories(user_id, repository_id)
63
- for repo in repos:
64
- yield repo
63
+ yield from repos
65
64
 
66
65
  @commit_node
67
66
  def commit(user_id: Optional[str] = None,
@@ -110,4 +109,4 @@ if __name__ == '__main__':
110
109
  # 'user_id' "strawberry-graphql"
111
110
  }
112
111
 
113
- graphinate.materialize("GitHub Repository Graph", repo_model, **params)
112
+ graphinate.materialize(repo_model, **params)
@@ -782,4 +782,4 @@ if __name__ == '__main__':
782
782
  choices = graphinate.tools.gui.modal_listbox_chooser('Choose Graph', atlas())
783
783
 
784
784
  for model in models(choices):
785
- graphinate.materialize(model.name, model)
785
+ graphinate.materialize(model)
@@ -1,5 +1,5 @@
1
1
  import graphinate
2
- from graphinate.materialize.matplotlib import show
2
+ from graphinate.materializers.matplotlib import plot
3
3
 
4
4
  graph_model = graphinate.model(name='Hailstone')
5
5
 
@@ -22,4 +22,4 @@ if __name__ == '__main__':
22
22
  'h_id': 7
23
23
  }
24
24
  graph = networkx_graph.build(**params)
25
- show(graph)
25
+ plot(graph)
@@ -0,0 +1,36 @@
1
+ import graphinate
2
+ import networkx as nx
3
+
4
+ N: int = 8
5
+
6
+ # Define GraphModel
7
+ graph_model = graphinate.GraphModel(name="Octagonal Graph")
8
+
9
+
10
+ # Register edges supplier function
11
+ @graph_model.edge()
12
+ def edge():
13
+ for i in range(N):
14
+ yield {'source': i, 'target': i + 1}
15
+ yield {'source': N, 'target': 0}
16
+
17
+
18
+ # Materialize the GraphModel
19
+ graphinate.materialize(graph_model)
20
+
21
+ # Or
22
+
23
+ # 1. Define Graph Builder
24
+ builder = graphinate.builders.NetworkxBuilder(model=graph_model)
25
+
26
+ # Then
27
+ # 2. Build the Graph object
28
+ graph: nx.Graph = builder.build()
29
+
30
+ # Then
31
+ # 3. Option A - Output to console
32
+ print(graph)
33
+
34
+ # Or
35
+ # 3. Option B - Output as a plot
36
+ graphinate.materializers.plot(graph)
@@ -11,5 +11,4 @@ for chunk in doc.noun_chunks:
11
11
  chunk.root.head.text)
12
12
 
13
13
  for token in doc:
14
- print(token.text, token.dep_, token.head.text, token.head.pos_,
15
- [child for child in token.children])
14
+ print(token.text, token.dep_, token.head.text, token.head.pos_, list(token.children))
@@ -4,7 +4,7 @@ import graphinate.builders
4
4
  import networkx as nx
5
5
  import requests
6
6
  from bs4 import BeautifulSoup
7
- from graphinate.materialize.matplotlib import show
7
+ from graphinate.materializers import plot
8
8
 
9
9
  DEPTH = 0
10
10
 
@@ -49,4 +49,4 @@ if __name__ == '__main__':
49
49
 
50
50
  nx_graph: nx.Graph = networkx_graph.build(url=base_url)
51
51
 
52
- show(nx_graph)
52
+ plot(nx_graph)
@@ -57,9 +57,15 @@ markdown_extensions:
57
57
  - pymdownx.superfences
58
58
 
59
59
  nav:
60
- - Introduction: index.md
60
+ - Home: index.md
61
61
  - Install: install.md
62
+ - Introduction: intro.md
63
+ - Quick Start: start.md
64
+ - Gallery: gallery.md
62
65
  - Usage: usage.md
66
+ - Examples: examples.md
67
+ # - Acknowledgements: acknowledgements.md
68
+
63
69
 
64
70
  extra:
65
71
  social:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Graphinate"
3
- version = "0.0.8"
3
+ version = "0.0.9"
4
4
  authors = [
5
5
  { name = "Eran Rivlis", email = "eran@rivlis.info" },
6
6
  ]
@@ -55,7 +55,6 @@ test = [
55
55
  # "pytest-xdist",
56
56
  ]
57
57
  plot = [
58
- "matplotlib",
59
58
  "scipy"
60
59
  ]
61
60
  server = [
@@ -104,6 +103,7 @@ exclude = [
104
103
  ".git",
105
104
  ".git-rewrite",
106
105
  ".hg",
106
+ ".idea",
107
107
  ".mypy_cache",
108
108
  ".nox",
109
109
  ".pants.d",
@@ -117,7 +117,6 @@ exclude = [
117
117
  "buck-out",
118
118
  "build",
119
119
  "dist",
120
- "node_modules",
121
120
  "venv",
122
121
  ]
123
122
 
@@ -1,6 +1,6 @@
1
1
  from . import builders
2
2
  from .builders import GraphType
3
- from .materialize import materialize
3
+ from .materializers import materialize
4
4
  from .modeling import UNIVERSE_NODE, GraphModel
5
5
 
6
6
 
@@ -4,7 +4,7 @@ import json
4
4
  import click
5
5
 
6
6
  from . import builders
7
- from .materialize import materialize
7
+ from .materializers import materialize
8
8
  from .modeling import GraphModel
9
9
  from .server import DEFAULT_PORT, run_graphql
10
10
  from .tools.importer import import_from_string
@@ -20,8 +20,7 @@ def cli(*args, **kwargs):
20
20
  def save(model, *args, **kwargs):
21
21
  graph_model: GraphModel = import_from_string(model) if isinstance(model, str) else model
22
22
  with open(f"{graph_model.name}.json", mode='w') as fp:
23
- materialize(title=graph_model.name,
24
- graph_model=graph_model,
23
+ materialize(model=graph_model,
25
24
  builder=builders.D3Builder,
26
25
  actualizer=functools.partial(json.dump, fp=fp, default=str))
27
26
 
@@ -31,7 +30,6 @@ def save(model, *args, **kwargs):
31
30
  @click.option('-p', '--port', type=int, default=DEFAULT_PORT)
32
31
  def server(model, port, *args, **kwargs):
33
32
  graph_model: GraphModel = import_from_string(model) if isinstance(model, str) else model
34
- materialize(title=graph_model.name,
35
- graph_model=graph_model,
33
+ materialize(model=graph_model,
36
34
  builder=builders.GraphQLBuilder,
37
35
  actualizer=functools.partial(run_graphql, port=port))
@@ -5,23 +5,26 @@ from typing import Callable, Optional
5
5
 
6
6
  from .. import builders, modeling, server
7
7
  from ..tools.gui import modal_radiobutton_chooser
8
- from .matplotlib import show
8
+ from .matplotlib import plot
9
+
10
+ graphql = server.run_graphql
9
11
 
10
12
 
11
13
  class Materializers(Enum):
12
- NetworkX = (builders.NetworkxBuilder, show)
14
+ NetworkX = (builders.NetworkxBuilder, plot)
13
15
  D3Graph = (builders.D3Builder, pprint)
14
- GraphQL = (builders.GraphQLBuilder, server.run_graphql)
15
- D3GraphQL = (builders.D3GraphQLBuilder, server.run_graphql)
16
+ GraphQL = (builders.GraphQLBuilder, graphql)
17
+ D3GraphQL = (builders.D3GraphQLBuilder, graphql)
16
18
 
17
19
 
18
- def materialize(title: str,
19
- graph_model: modeling.GraphModel,
20
+ def materialize(model: modeling.GraphModel,
21
+ title: Optional[str] = None,
20
22
  graph_type: builders.GraphType = builders.GraphType.Graph,
21
23
  default_node_attributes: Optional[Mapping] = None,
22
24
  builder: Optional[type[builders.Builder]] = None,
23
25
  actualizer: Optional[Callable] = None,
24
26
  **kwargs):
27
+ title = title or model.name
25
28
  if builder is None and actualizer is None:
26
29
  result = modal_radiobutton_chooser(title,
27
30
  options={m.name: m.value for m in Materializers},
@@ -30,8 +33,11 @@ def materialize(title: str,
30
33
  builder, actualizer = result[1]
31
34
 
32
35
  materialized_graph = builders.build(builder,
33
- graph_model,
36
+ model,
34
37
  graph_type,
35
38
  default_node_attributes=default_node_attributes,
36
39
  **kwargs)
37
40
  actualizer(materialized_graph)
41
+
42
+
43
+ __all__ = ('materialize', 'plot', 'graphql')
@@ -1,15 +1,15 @@
1
1
  import networkx as nx
2
- from matplotlib import pyplot as plt
2
+ from matplotlib import pyplot
3
3
 
4
4
  from ..color import node_color_mapping
5
5
 
6
6
 
7
- def nodes_labels(graph: nx.Graph):
7
+ def _nodes_labels(graph: nx.Graph):
8
8
  # return {node: data.get('label', node) or node for node, data in graph.nodes.data()}
9
9
  return nx.get_node_attributes(graph, 'label')
10
10
 
11
11
 
12
- def edges_labels(graph: nx.Graph):
12
+ def _edges_labels(graph: nx.Graph):
13
13
  return nx.get_edge_attributes(graph, 'label')
14
14
 
15
15
 
@@ -22,7 +22,7 @@ def draw(graph: nx.Graph, with_labels=True):
22
22
  draw_params.update(
23
23
  {
24
24
  'with_labels': True,
25
- 'labels': nodes_labels(graph),
25
+ 'labels': _nodes_labels(graph),
26
26
  'font_size': 6,
27
27
  'font_color': 'blue',
28
28
  # 'horizontalalignment':'left',
@@ -39,9 +39,9 @@ def draw(graph: nx.Graph, with_labels=True):
39
39
 
40
40
  node_color = list(node_color_mapping(graph).values())
41
41
  nx.draw(graph, pos, node_color=node_color, **draw_params)
42
- nx.draw_networkx_edge_labels(graph, pos, edge_labels=edges_labels(graph), font_color='red', font_size=6)
42
+ nx.draw_networkx_edge_labels(graph, pos, edge_labels=_edges_labels(graph), font_color='red', font_size=6)
43
43
 
44
44
 
45
- def show(graph: nx.Graph):
45
+ def plot(graph: nx.Graph):
46
46
  draw(graph)
47
- plt.show()
47
+ pyplot.show()
@@ -129,7 +129,7 @@ class GraphModel:
129
129
  key: Optional[Extractor] = None,
130
130
  value: Optional[Extractor] = None,
131
131
  label: Optional[Extractor] = None) -> Callable[[Items], None]:
132
- """Decorator to Register a Generator of node payloads as a source to materialize Graph Nodes. It creates a
132
+ """Decorator to Register a Generator of node payloads as a source to create Graph Nodes. It creates a
133
133
  NodeModel object.
134
134
  :param _type: Optional source for the Node Type. Defaults to use Generator function name as the Node Type.
135
135
  :param parent_type: Optional parent Node Type. Defaults to UNIVERSE_NODE
@@ -170,7 +170,7 @@ class GraphModel:
170
170
  value: Optional[Extractor] = None,
171
171
  weight: Union[float, Callable[[Any], float]] = 1.0,
172
172
  ) -> Callable[[Items], None]:
173
- """Decorator to Register a Generator of edge payloads as a source to materialize Graph Edges. It creates an Edge
173
+ """Decorator to Register a Generator of edge payloads as a source to create Graph Edges. It creates an Edge
174
174
  Generator function.
175
175
  :param _type:
176
176
  :param source:
@@ -1,7 +0,0 @@
1
- # Graphinate. Data to Graphs.
2
- ![PyPI](https://img.shields.io/pypi/v/graphinate) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/graphinate) [![Contributors](https://img.shields.io/github/contributors/erivlis/graphinate.svg)](https://github.com/erivlis/graphinate/graphs/contributors) [![Tests](https://github.com/erivlis/graphinate/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/erivlis/graphinate/actions/workflows/test.yml) [![Publish](https://github.com/erivlis/graphinate/actions/workflows/publish.yml/badge.svg)](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
3
-
4
-
5
- ## Edge First
6
-
7
- ## Node First
@@ -1,9 +0,0 @@
1
- # Install
2
-
3
- ## PyPI
4
-
5
- Graphinate is available on PyPI:
6
-
7
- ```shell
8
- python -m pip install graphinate
9
- ```
@@ -1,10 +0,0 @@
1
- # Usage
2
-
3
- ## Model
4
-
5
- ## Build
6
-
7
- ## Materialize
8
-
9
-
10
-
File without changes
File without changes
File without changes