Graphinate 0.0.6__tar.gz → 0.0.8__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.
- graphinate-0.0.8/.github/workflows/codeql.yml +82 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/.github/workflows/test-python-beta.yml +1 -1
- graphinate-0.0.8/PKG-INFO +238 -0
- graphinate-0.0.8/README.md +191 -0
- graphinate-0.0.8/docs/index.md +7 -0
- {graphinate-0.0.6/docs → graphinate-0.0.8}/docs/install.md +1 -1
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/code/python_ast.py +1 -1
- graphinate-0.0.8/examples/code/requirements.txt +1 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/math/graph_atlas.py +32 -32
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/web/requirements.txt +0 -1
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/web/web_graph.py +2 -8
- graphinate-0.0.8/mkdocs.yml +79 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/pyproject.toml +74 -17
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/__init__.py +1 -1
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/builders.py +79 -56
- graphinate-0.0.8/src/graphinate/cli.py +37 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/color.py +7 -7
- graphinate-0.0.8/src/graphinate/materialize/__init__.py +37 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/materialize/matplotlib.py +8 -5
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/modeling.py +32 -38
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/__init__.py +3 -2
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/starlette/__init__.py +2 -2
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/starlette/views.py +1 -2
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/__init__.py +1 -1
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/tools/gui.py +1 -1
- graphinate-0.0.8/src/graphinate/tools/importer.py +34 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/tools/mutators.py +11 -9
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/typing.py +6 -5
- graphinate-0.0.6/PKG-INFO +0 -116
- graphinate-0.0.6/README.md +0 -67
- graphinate-0.0.6/examples/code/requirements.txt +0 -1
- graphinate-0.0.6/src/graphinate/cli.py +0 -16
- graphinate-0.0.6/src/graphinate/materialize/__init__.py +0 -31
- {graphinate-0.0.6 → graphinate-0.0.8}/.github/workflows/publish.yml +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/.github/workflows/test.yml +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/.gitignore +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/LICENSE +0 -0
- {graphinate-0.0.6/docs → graphinate-0.0.8}/docs/assets/images/network_graph.png +0 -0
- {graphinate-0.0.6/docs → graphinate-0.0.8}/docs/usage.md +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/code/call_graph.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/ethernet/traceroute.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/genric_graph.graphql +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/github/_client.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/github/followers.graphql +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/github/followers.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/github/graphql.config.yml +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/github/repositories.graphql +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/github/repositories.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/graphql.config.yml +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/math/hailstone.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/examples/text/nlp_graph.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/playground/grap_genus.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/playground/house_of_graphs.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/__main__.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/graphiql/__init__.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/graphiql/index.html +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/static/images/network_graph.png +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/viewer/__init__.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/viewer/index.html +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/voyager/__init__.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/server/web/voyager/index.html +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/tools/__init__.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/src/graphinate/tools/fs.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/tests/conftest.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/tests/graphinate/test_builders.py +0 -0
- {graphinate-0.0.6 → graphinate-0.0.8}/tests/graphinate/test_modeling.py +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [ "master" ]
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: [ "master" ]
|
|
20
|
+
schedule:
|
|
21
|
+
- cron: '44 6 * * 4'
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
analyze:
|
|
25
|
+
name: Analyze
|
|
26
|
+
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
|
27
|
+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
|
28
|
+
# - https://gh.io/supported-runners-and-hardware-resources
|
|
29
|
+
# - https://gh.io/using-larger-runners
|
|
30
|
+
# Consider using larger runners for possible analysis time improvements.
|
|
31
|
+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
|
32
|
+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
|
|
33
|
+
permissions:
|
|
34
|
+
actions: read
|
|
35
|
+
contents: read
|
|
36
|
+
security-events: write
|
|
37
|
+
|
|
38
|
+
strategy:
|
|
39
|
+
fail-fast: false
|
|
40
|
+
matrix:
|
|
41
|
+
language: [ 'javascript', 'python' ]
|
|
42
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
|
|
43
|
+
# Use only 'java' to analyze code written in Java, Kotlin or both
|
|
44
|
+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
|
45
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
46
|
+
|
|
47
|
+
steps:
|
|
48
|
+
- name: Checkout repository
|
|
49
|
+
uses: actions/checkout@v3
|
|
50
|
+
|
|
51
|
+
# Initializes the CodeQL tools for scanning.
|
|
52
|
+
- name: Initialize CodeQL
|
|
53
|
+
uses: github/codeql-action/init@v2
|
|
54
|
+
with:
|
|
55
|
+
languages: ${{ matrix.language }}
|
|
56
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
57
|
+
# By default, queries listed here will override any specified in a config file.
|
|
58
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
59
|
+
|
|
60
|
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
61
|
+
# queries: security-extended,security-and-quality
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
|
|
65
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
66
|
+
- name: Autobuild
|
|
67
|
+
uses: github/codeql-action/autobuild@v2
|
|
68
|
+
|
|
69
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
70
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
71
|
+
|
|
72
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
|
73
|
+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
|
74
|
+
|
|
75
|
+
# - run: |
|
|
76
|
+
# echo "Run, Build Application using script"
|
|
77
|
+
# ./location_of_script_within_repo/buildscript.sh
|
|
78
|
+
|
|
79
|
+
- name: Perform CodeQL Analysis
|
|
80
|
+
uses: github/codeql-action/analyze@v2
|
|
81
|
+
with:
|
|
82
|
+
category: "/language:${{matrix.language}}"
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Graphinate
|
|
3
|
+
Version: 0.0.8
|
|
4
|
+
Summary: Graphinate. Data to Graphs.
|
|
5
|
+
Project-URL: Homepage, https://github.com/erivlis/graphinate
|
|
6
|
+
Project-URL: Documentation, https://github.com/erivlis/graphinate#README.md
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/erivlis/graphinate/issues
|
|
8
|
+
Project-URL: Source, https://github.com/erivlis/graphinate
|
|
9
|
+
Author-email: Eran Rivlis <eran@rivlis.info>
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: declarative,graph
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Information Technology
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Requires-Dist: click>=8
|
|
30
|
+
Requires-Dist: inflect>=7
|
|
31
|
+
Requires-Dist: loguru>=0.7
|
|
32
|
+
Requires-Dist: matplotlib>=3.7
|
|
33
|
+
Requires-Dist: networkx>=3
|
|
34
|
+
Requires-Dist: strawberry-graphql[asgi,opentelemetry]
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
37
|
+
Provides-Extra: plot
|
|
38
|
+
Requires-Dist: matplotlib; extra == 'plot'
|
|
39
|
+
Requires-Dist: scipy; extra == 'plot'
|
|
40
|
+
Provides-Extra: server
|
|
41
|
+
Requires-Dist: starlette-prometheus; extra == 'server'
|
|
42
|
+
Requires-Dist: uvicorn[standard]; extra == 'server'
|
|
43
|
+
Provides-Extra: test
|
|
44
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
|
|
45
|
+
Requires-Dist: pytest>=7.3.2; extra == 'test'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# Graphinate. Data to Graphs.
|
|
49
|
+
|
|
50
|
+
## ⚠️ **Under Development!** ⚠️
|
|
51
|
+
|
|
52
|
+
This library is alpha-quality
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+

|
|
56
|
+

|
|
57
|
+

|
|
58
|
+

|
|
59
|
+

|
|
60
|
+
[](https://github.com/erivlis/graphinate/graphs/contributors)
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
|
|
64
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
|
|
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
|
+
## Introduction
|
|
77
|
+
|
|
78
|
+
### What is Graphinate?
|
|
79
|
+
|
|
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/)
|
|
82
|
+
|
|
83
|
+
### What is a Graph?
|
|
84
|
+
|
|
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)
|
|
92
|
+
|
|
93
|
+
### What is Data?
|
|
94
|
+
|
|
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)
|
|
100
|
+
|
|
101
|
+
### Defining a Graph
|
|
102
|
+
|
|
103
|
+
One can define Graphs in two general ways:
|
|
104
|
+
|
|
105
|
+
#### Edge first
|
|
106
|
+
|
|
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.
|
|
110
|
+
|
|
111
|
+
In this case one defines the **edges explicitly** and the **nodes implicitly**.
|
|
112
|
+
|
|
113
|
+
Such graph is focused more on the _relationships_ or the _structure_ of the Graph than on the nodes themselves.
|
|
114
|
+
|
|
115
|
+
#### Node first
|
|
116
|
+
|
|
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.
|
|
120
|
+
|
|
121
|
+
In this case **both nodes and the edges** are defines **explicitly**.
|
|
122
|
+
|
|
123
|
+
Such a graph has focus first on the nodes and later on the relationship between them.
|
|
124
|
+
|
|
125
|
+
## Gallery
|
|
126
|
+
|
|
127
|
+

|
|
128
|
+

|
|
129
|
+

|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
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
|
|
148
|
+
|
|
149
|
+
## Guide
|
|
150
|
+
|
|
151
|
+
### By Convention
|
|
152
|
+
|
|
153
|
+
https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/followers.py#L1
|
|
154
|
+
|
|
155
|
+
### By Configuration
|
|
156
|
+
|
|
157
|
+
https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/repositories.py#L1
|
|
158
|
+
|
|
159
|
+
## CLI
|
|
160
|
+
|
|
161
|
+
### Commands
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
Usage: python -m graphinate [OPTIONS] COMMAND [ARGS]...
|
|
165
|
+
|
|
166
|
+
Options:
|
|
167
|
+
--help Show this message and exit.
|
|
168
|
+
|
|
169
|
+
Commands:
|
|
170
|
+
save
|
|
171
|
+
server
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Save
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
Usage: python -m graphinate save [OPTIONS] MODEL
|
|
178
|
+
|
|
179
|
+
Options:
|
|
180
|
+
--help Show this message and exit.
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### Server
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
Usage: python -m graphinate server [OPTIONS] MODEL
|
|
187
|
+
|
|
188
|
+
Options:
|
|
189
|
+
-p, --port INTEGER
|
|
190
|
+
--help Show this message and exit.
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
### Lint
|
|
196
|
+
|
|
197
|
+
```shell
|
|
198
|
+
ruff check src
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Docs
|
|
202
|
+
|
|
203
|
+
```shell
|
|
204
|
+
python -m mkdocs build
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Build
|
|
208
|
+
|
|
209
|
+
```shell
|
|
210
|
+
python -m build
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Test
|
|
214
|
+
|
|
215
|
+
```shell
|
|
216
|
+
python -m pytest ./tests --cov=./src --cov-branch --cov-report=xml --junitxml=test_results.xml
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Acknowledgements
|
|
220
|
+
|
|
221
|
+
### Dependencies
|
|
222
|
+
|
|
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>
|
|
224
|
+
<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
|
+
<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
|
+
<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
|
+
<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
|
+
<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
|
+
|
|
230
|
+
### Dev Tools
|
|
231
|
+
|
|
232
|
+
<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>
|
|
233
|
+
<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>
|
|
234
|
+
<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>
|
|
235
|
+
|
|
236
|
+
### IDE
|
|
237
|
+
|
|
238
|
+
<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,191 @@
|
|
|
1
|
+
# Graphinate. Data to Graphs.
|
|
2
|
+
|
|
3
|
+
## ⚠️ **Under Development!** ⚠️
|
|
4
|
+
|
|
5
|
+
This library is alpha-quality
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
[](https://github.com/erivlis/graphinate/graphs/contributors)
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
|
|
17
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
|
|
18
|
+
|
|
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
|
+
## Introduction
|
|
30
|
+
|
|
31
|
+
### What is Graphinate?
|
|
32
|
+
|
|
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/)
|
|
35
|
+
|
|
36
|
+
### What is a Graph?
|
|
37
|
+
|
|
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
|
+
> — [https://mathworld.wolfram.com/Graph.html](https://mathworld.wolfram.com/Graph.html)
|
|
45
|
+
|
|
46
|
+
### What is Data?
|
|
47
|
+
|
|
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
|
+
> — [https://en.wikipedia.org/wiki/Data](https://en.wikipedia.org/wiki/Data)
|
|
53
|
+
|
|
54
|
+
### Defining a Graph
|
|
55
|
+
|
|
56
|
+
One can define Graphs in two general ways:
|
|
57
|
+
|
|
58
|
+
#### Edge first
|
|
59
|
+
|
|
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.
|
|
63
|
+
|
|
64
|
+
In this case one defines the **edges explicitly** and the **nodes implicitly**.
|
|
65
|
+
|
|
66
|
+
Such graph is focused more on the _relationships_ or the _structure_ of the Graph than on the nodes themselves.
|
|
67
|
+
|
|
68
|
+
#### Node first
|
|
69
|
+
|
|
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.
|
|
73
|
+
|
|
74
|
+
In this case **both nodes and the edges** are defines **explicitly**.
|
|
75
|
+
|
|
76
|
+
Such a graph has focus first on the nodes and later on the relationship between them.
|
|
77
|
+
|
|
78
|
+
## Gallery
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+

|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
## Examples
|
|
85
|
+
|
|
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
|
|
101
|
+
|
|
102
|
+
## Guide
|
|
103
|
+
|
|
104
|
+
### By Convention
|
|
105
|
+
|
|
106
|
+
https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/followers.py#L1
|
|
107
|
+
|
|
108
|
+
### By Configuration
|
|
109
|
+
|
|
110
|
+
https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/repositories.py#L1
|
|
111
|
+
|
|
112
|
+
## CLI
|
|
113
|
+
|
|
114
|
+
### Commands
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
Usage: python -m graphinate [OPTIONS] COMMAND [ARGS]...
|
|
118
|
+
|
|
119
|
+
Options:
|
|
120
|
+
--help Show this message and exit.
|
|
121
|
+
|
|
122
|
+
Commands:
|
|
123
|
+
save
|
|
124
|
+
server
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Save
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Usage: python -m graphinate save [OPTIONS] MODEL
|
|
131
|
+
|
|
132
|
+
Options:
|
|
133
|
+
--help Show this message and exit.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Server
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Usage: python -m graphinate server [OPTIONS] MODEL
|
|
140
|
+
|
|
141
|
+
Options:
|
|
142
|
+
-p, --port INTEGER
|
|
143
|
+
--help Show this message and exit.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
### Lint
|
|
149
|
+
|
|
150
|
+
```shell
|
|
151
|
+
ruff check src
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Docs
|
|
155
|
+
|
|
156
|
+
```shell
|
|
157
|
+
python -m mkdocs build
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Build
|
|
161
|
+
|
|
162
|
+
```shell
|
|
163
|
+
python -m build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Test
|
|
167
|
+
|
|
168
|
+
```shell
|
|
169
|
+
python -m pytest ./tests --cov=./src --cov-branch --cov-report=xml --junitxml=test_results.xml
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Acknowledgements
|
|
173
|
+
|
|
174
|
+
### Dependencies
|
|
175
|
+
|
|
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>
|
|
177
|
+
<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
|
+
<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
|
+
<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
|
+
<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
|
+
<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
|
+
|
|
183
|
+
### Dev Tools
|
|
184
|
+
|
|
185
|
+
<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>
|
|
186
|
+
<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>
|
|
187
|
+
<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>
|
|
188
|
+
|
|
189
|
+
### IDE
|
|
190
|
+
|
|
191
|
+
<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,7 @@
|
|
|
1
|
+
# Graphinate. Data to Graphs.
|
|
2
|
+
  [](https://github.com/erivlis/graphinate/graphs/contributors) [](https://github.com/erivlis/graphinate/actions/workflows/test.yml) [](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Edge First
|
|
6
|
+
|
|
7
|
+
## Node First
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PyGithub
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
import networkx as nx
|
|
4
|
-
|
|
5
3
|
import graphinate
|
|
6
4
|
import graphinate.tools.gui
|
|
5
|
+
import networkx as nx
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
def
|
|
8
|
+
def atlas():
|
|
10
9
|
ladder_size = 16
|
|
11
10
|
ladder = nx.ladder_graph(ladder_size)
|
|
12
11
|
|
|
@@ -43,14 +42,32 @@ def get_graph():
|
|
|
43
42
|
spiral = nx.Graph(e for e in spiral_edges(128, 8))
|
|
44
43
|
|
|
45
44
|
def spiral_torus_edges(n, k):
|
|
46
|
-
yield from spiral_edges(n-1, k)
|
|
45
|
+
yield from spiral_edges(n - 1, k)
|
|
47
46
|
yield n - 1, 0
|
|
48
47
|
for i in range(k):
|
|
49
48
|
yield i, n - k + i
|
|
50
49
|
|
|
51
50
|
spiral_torus = nx.Graph(spiral_torus_edges(128, 8))
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
graphs = {
|
|
53
|
+
'Tetrahedron': nx.tetrahedral_graph(),
|
|
54
|
+
'Cube': nx.hypercube_graph(3),
|
|
55
|
+
'Octahedron': nx.octahedral_graph(),
|
|
56
|
+
'Dodecahedron': nx.dodecahedral_graph(),
|
|
57
|
+
'Icosahedron': nx.icosahedral_graph(),
|
|
58
|
+
'Tesseract': nx.hypercube_graph(4),
|
|
59
|
+
'Truncated Cube': nx.truncated_cube_graph(),
|
|
60
|
+
'Truncated Tetrahedron': nx.truncated_tetrahedron_graph(),
|
|
61
|
+
'Ladder': ladder,
|
|
62
|
+
'Ring': ladder_ring,
|
|
63
|
+
'Möbius': ladder_mobius,
|
|
64
|
+
'Cylinder': cylinder,
|
|
65
|
+
'Spiral': spiral,
|
|
66
|
+
'Spiral Torus': spiral_torus,
|
|
67
|
+
'Circulant[10,[2]]': nx.circulant_graph(10, [2])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
adjacency_mapping = {
|
|
54
71
|
'Buckyball - Truncated Icosahedral Graph': {
|
|
55
72
|
1: [2, 3, 4],
|
|
56
73
|
2: [1, 55, 56],
|
|
@@ -739,38 +756,17 @@ def get_graph():
|
|
|
739
756
|
def edges_iter(adjacency_list: dict[int, [int]]):
|
|
740
757
|
yield from itertools.chain.from_iterable(((k, t) for t in v) for k, v in adjacency_list.items())
|
|
741
758
|
|
|
742
|
-
edges = ((
|
|
759
|
+
edges = ((name, edges_iter(adjacency_list)) for name, adjacency_list in adjacency_mapping.items())
|
|
743
760
|
|
|
744
|
-
graphs
|
|
761
|
+
graphs.update({n: nx.Graph(list(e)) for n, e in edges})
|
|
745
762
|
|
|
746
|
-
|
|
747
|
-
'Tetrahedron': nx.tetrahedral_graph(),
|
|
748
|
-
'Cube': nx.hypercube_graph(3),
|
|
749
|
-
'Octahedron': nx.octahedral_graph(),
|
|
750
|
-
'Dodecahedron': nx.dodecahedral_graph(),
|
|
751
|
-
'Icosahedron': nx.icosahedral_graph(),
|
|
752
|
-
'Tesseract': nx.hypercube_graph(4),
|
|
753
|
-
'Truncated Cube': nx.truncated_cube_graph(),
|
|
754
|
-
'Truncated Tetrahedron': nx.truncated_tetrahedron_graph(),
|
|
755
|
-
'Ladder': ladder,
|
|
756
|
-
'Ring': ladder_ring,
|
|
757
|
-
'Möbius': ladder_mobius,
|
|
758
|
-
'Cylinder': cylinder,
|
|
759
|
-
'Spiral': spiral,
|
|
760
|
-
'Spiral Torus': spiral_torus,
|
|
761
|
-
'Circulant[10,[2]]': nx.circulant_graph(10, [2])
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
options.update(graphs)
|
|
765
|
-
|
|
766
|
-
# return graphinate.tools.gui.modal_radiobutton_chooser('Choose Graph', options)
|
|
767
|
-
yield from graphinate.tools.gui.modal_listbox_chooser('Choose Graph', options)
|
|
763
|
+
return graphs
|
|
768
764
|
|
|
769
765
|
|
|
770
|
-
def models():
|
|
766
|
+
def models(iterable):
|
|
771
767
|
graph_model = graphinate.GraphModel('Graph Atlas')
|
|
772
768
|
|
|
773
|
-
graph_atlas = nx.disjoint_union_all(g for _, g in
|
|
769
|
+
graph_atlas = nx.disjoint_union_all(g for _, g in iterable)
|
|
774
770
|
|
|
775
771
|
@graph_model.edge()
|
|
776
772
|
def edge():
|
|
@@ -780,6 +776,10 @@ def models():
|
|
|
780
776
|
yield graph_model
|
|
781
777
|
|
|
782
778
|
|
|
779
|
+
model = next(models(atlas().items()))
|
|
780
|
+
|
|
783
781
|
if __name__ == '__main__':
|
|
784
|
-
|
|
782
|
+
choices = graphinate.tools.gui.modal_listbox_chooser('Choose Graph', atlas())
|
|
783
|
+
|
|
784
|
+
for model in models(choices):
|
|
785
785
|
graphinate.materialize(model.name, model)
|