mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
Changelog: https://networkx.org/documentation/stable/release/release_dev.html Minor release with new algorithms and bug fixes since 3.5. Add test.sh to verify graph creation, pathfinding, and topological sort. Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
24 lines
554 B
Bash
Executable File
24 lines
554 B
Bash
Executable File
#!/bin/sh
|
|
[ "$1" = python3-networkx ] || exit 0
|
|
python3 - << 'EOF'
|
|
import networkx
|
|
assert networkx.__version__, "networkx version is empty"
|
|
|
|
import networkx as nx
|
|
|
|
G = nx.Graph()
|
|
G.add_nodes_from([1, 2, 3, 4])
|
|
G.add_edges_from([(1, 2), (2, 3), (3, 4)])
|
|
|
|
assert G.number_of_nodes() == 4
|
|
assert G.number_of_edges() == 3
|
|
assert nx.is_connected(G)
|
|
|
|
path = nx.shortest_path(G, source=1, target=4)
|
|
assert path == [1, 2, 3, 4], f"unexpected path: {path}"
|
|
|
|
D = nx.DiGraph()
|
|
D.add_edges_from([(1, 2), (2, 3)])
|
|
assert list(nx.topological_sort(D)) == [1, 2, 3]
|
|
EOF
|