-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick start added to documentation, automatic testing added..
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: | | ||
pip install . | ||
- name: Run tests | ||
run: | | ||
python -m unittest discover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
First import the necessary libraries: | ||
.. literalinclude:: quick_start.py | ||
:start-after: example-st\u0061rt | ||
:lines: 1-4 | ||
:dedent: 0 | ||
Next, create a simple graph with self-avoiding edges (SAE) between nodes. | ||
.. literalinclude:: quick_start.py | ||
:start-after: example-st\u0061rt | ||
:lines: 6-8 | ||
Now, find all self-avoiding paths from a given start node to a target node. | ||
.. literalinclude:: quick_start.py | ||
:start-after: example-st\u0061rt | ||
:lines: 11-16 | ||
Finally, visualize the graph. | ||
.. literalinclude:: quick_start.py | ||
:start-after: example-st\u0061rt | ||
:lines: 18 | ||
.. figure:: images/01.png | ||
:scale: 80 % | ||
""" | ||
|
||
# example-start | ||
import networkx as nx | ||
import matplotlib.pyplot as plt | ||
from netsci.plot import plot_graph | ||
from netsci.analysis import find_sap | ||
|
||
G = nx.Graph() | ||
edges = [("A", "B"), ("A", "C"), ("B", "D"), ("B", "E"), ("C", "F"), ("E", "F")] | ||
G.add_edges_from(edges) | ||
|
||
# Find all self-avoiding paths from 'A' to 'F' | ||
start_node = "A" | ||
target_node = "F" | ||
all_saps = list(find_sap(G, start_node, target_node)) | ||
|
||
for path in all_saps: | ||
print("->".join(path)) | ||
|
||
plot_graph(G, seed=2, figsize=(3, 3)) | ||
import os | ||
os.makedirs("images", exist_ok=True) | ||
plt.savefig("images/01.png", bbox_inches="tight") | ||
|
||
# example-end |