test
This commit is contained in:
9
main.py
9
main.py
@@ -1,17 +1,20 @@
|
|||||||
import networkx as nx
|
import networkx as nx
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
G = nx.Graph()
|
# Tree
|
||||||
|
G = nx.DiGraph()
|
||||||
G.add_node("A")
|
G.add_node("A")
|
||||||
G.add_node("B")
|
G.add_node("B")
|
||||||
G.add_node(3)
|
G.add_node("C")
|
||||||
G.add_edge("A", "B")
|
G.add_edge("A", "B")
|
||||||
G.add_edge("B", 3)
|
G.add_edge("B", "C")
|
||||||
print(G.nodes())
|
print(G.nodes())
|
||||||
print(G.edges())
|
print(G.edges())
|
||||||
print(G.degree())
|
print(G.degree())
|
||||||
|
|
||||||
nx.draw(G, with_labels=True)
|
nx.draw(G, with_labels=True)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user