forked from caten/DiscreteNeuralNets
26 lines
731 B
Python
26 lines
731 B
Python
"""
|
|
Graphs test
|
|
"""
|
|
import src
|
|
from graphs import Graph, load_graph_from_file, random_tree
|
|
|
|
print('Create a graph on the vertex set {a,b,c} with edges {a,b} and {c,b}.')
|
|
G = Graph(('a', 'b', 'c'), (('a', 'b'), ('c', 'b')))
|
|
print('Display the neighbors of the vertex b.')
|
|
print(tuple(G.neighbors('b')))
|
|
print('Display information about our graph.')
|
|
print(G)
|
|
print()
|
|
|
|
print('Write our graph to a file.')
|
|
print('The file will be appended to if it already exists.')
|
|
G.write_to_file('graphs')
|
|
print('We can read the data of this graph back from the file.')
|
|
print(load_graph_from_file('graphs', 0))
|
|
print()
|
|
|
|
print('Create a random tree with 10 vertices.')
|
|
T = random_tree(range(10))
|
|
print('Display information about our tree.')
|
|
print(T)
|