rm CondaPkg environment
This commit is contained in:
2
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/README.txt
vendored
Normal file
2
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/README.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Basic
|
||||
-----
|
||||
BIN
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/__pycache__/plot_properties.cpython-311.pyc
vendored
Normal file
BIN
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/__pycache__/plot_properties.cpython-311.pyc
vendored
Normal file
Binary file not shown.
BIN
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/__pycache__/plot_read_write.cpython-311.pyc
vendored
Normal file
BIN
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/__pycache__/plot_read_write.cpython-311.pyc
vendored
Normal file
Binary file not shown.
BIN
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/__pycache__/plot_simple_graph.cpython-311.pyc
vendored
Normal file
BIN
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/__pycache__/plot_simple_graph.cpython-311.pyc
vendored
Normal file
Binary file not shown.
49
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/plot_properties.py
vendored
Normal file
49
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/plot_properties.py
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
==========
|
||||
Properties
|
||||
==========
|
||||
|
||||
Compute some network properties for the lollipop graph.
|
||||
"""
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import networkx as nx
|
||||
|
||||
G = nx.lollipop_graph(4, 6)
|
||||
|
||||
pathlengths = []
|
||||
|
||||
print("source vertex {target:length, }")
|
||||
for v in G.nodes():
|
||||
spl = dict(nx.single_source_shortest_path_length(G, v))
|
||||
print(f"{v} {spl} ")
|
||||
for p in spl:
|
||||
pathlengths.append(spl[p])
|
||||
|
||||
print()
|
||||
print(f"average shortest path length {sum(pathlengths) / len(pathlengths)}")
|
||||
|
||||
# histogram of path lengths
|
||||
dist = {}
|
||||
for p in pathlengths:
|
||||
if p in dist:
|
||||
dist[p] += 1
|
||||
else:
|
||||
dist[p] = 1
|
||||
|
||||
print()
|
||||
print("length #paths")
|
||||
verts = dist.keys()
|
||||
for d in sorted(verts):
|
||||
print(f"{d} {dist[d]}")
|
||||
|
||||
print(f"radius: {nx.radius(G)}")
|
||||
print(f"diameter: {nx.diameter(G)}")
|
||||
print(f"eccentricity: {nx.eccentricity(G)}")
|
||||
print(f"center: {nx.center(G)}")
|
||||
print(f"periphery: {nx.periphery(G)}")
|
||||
print(f"density: {nx.density(G)}")
|
||||
|
||||
pos = nx.spring_layout(G, seed=3068) # Seed layout for reproducibility
|
||||
nx.draw(G, pos=pos, with_labels=True)
|
||||
plt.show()
|
||||
24
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/plot_read_write.py
vendored
Normal file
24
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/plot_read_write.py
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
======================
|
||||
Read and write graphs.
|
||||
======================
|
||||
|
||||
Read and write graphs.
|
||||
"""
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import networkx as nx
|
||||
|
||||
G = nx.grid_2d_graph(5, 5) # 5x5 grid
|
||||
|
||||
# print the adjacency list
|
||||
for line in nx.generate_adjlist(G):
|
||||
print(line)
|
||||
# write edgelist to grid.edgelist
|
||||
nx.write_edgelist(G, path="grid.edgelist", delimiter=":")
|
||||
# read edgelist from grid.edgelist
|
||||
H = nx.read_edgelist(path="grid.edgelist", delimiter=":")
|
||||
|
||||
pos = nx.spring_layout(H, seed=200)
|
||||
nx.draw(H, pos)
|
||||
plt.show()
|
||||
60
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/plot_simple_graph.py
vendored
Normal file
60
.CondaPkg/env/share/doc/networkx-3.1/examples/basic/plot_simple_graph.py
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
============
|
||||
Simple graph
|
||||
============
|
||||
|
||||
Draw simple graph with manual layout.
|
||||
"""
|
||||
|
||||
import networkx as nx
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
G = nx.Graph()
|
||||
G.add_edge(1, 2)
|
||||
G.add_edge(1, 3)
|
||||
G.add_edge(1, 5)
|
||||
G.add_edge(2, 3)
|
||||
G.add_edge(3, 4)
|
||||
G.add_edge(4, 5)
|
||||
|
||||
# explicitly set positions
|
||||
pos = {1: (0, 0), 2: (-1, 0.3), 3: (2, 0.17), 4: (4, 0.255), 5: (5, 0.03)}
|
||||
|
||||
options = {
|
||||
"font_size": 36,
|
||||
"node_size": 3000,
|
||||
"node_color": "white",
|
||||
"edgecolors": "black",
|
||||
"linewidths": 5,
|
||||
"width": 5,
|
||||
}
|
||||
nx.draw_networkx(G, pos, **options)
|
||||
|
||||
# Set margins for the axes so that nodes aren't clipped
|
||||
ax = plt.gca()
|
||||
ax.margins(0.20)
|
||||
plt.axis("off")
|
||||
plt.show()
|
||||
|
||||
# %%
|
||||
# A directed graph
|
||||
|
||||
G = nx.DiGraph([(0, 3), (1, 3), (2, 4), (3, 5), (3, 6), (4, 6), (5, 6)])
|
||||
|
||||
# group nodes by column
|
||||
left_nodes = [0, 1, 2]
|
||||
middle_nodes = [3, 4]
|
||||
right_nodes = [5, 6]
|
||||
|
||||
# set the position according to column (x-coord)
|
||||
pos = {n: (0, i) for i, n in enumerate(left_nodes)}
|
||||
pos.update({n: (1, i + 0.5) for i, n in enumerate(middle_nodes)})
|
||||
pos.update({n: (2, i + 0.5) for i, n in enumerate(right_nodes)})
|
||||
|
||||
nx.draw_networkx(G, pos, **options)
|
||||
|
||||
# Set margins for the axes so that nodes aren't clipped
|
||||
ax = plt.gca()
|
||||
ax.margins(0.20)
|
||||
plt.axis("off")
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user