def test_multi_sequence(): # Test nongraphical multi sequence seq = [1000, 3, 3, 3, 3, 2, 2, 2, 1, 1] assert_false(nx.is_multigraphical(seq)) # Test small graphical multi sequence seq = [6, 5, 4, 4, 2, 1, 1, 1] assert_true(nx.is_multigraphical(seq)) # Test for negative integer in sequence seq = [6, 5, 4, -4, 2, 1, 1, 1] assert_false(nx.is_multigraphical(seq)) # Test for sequence with odd sum seq = [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4] assert_false(nx.is_multigraphical(seq))
def test_multi_sequence(): # Test nongraphical multi sequence seq=[1000,3,3,3,3,2,2,2,1,1] assert_false(nx.is_multigraphical(seq)) # Test small graphical multi sequence seq=[6,5,4,4,2,1,1,1] assert_true(nx.is_multigraphical(seq)) # Test for negative integer in sequence seq=[6,5,4,-4,2,1,1,1] assert_false(nx.is_multigraphical(seq)) # Test for sequence with odd sum seq=[1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4] assert_false(nx.is_multigraphical(seq))
def show_result(): m = path.get() #input user graph with open(m) as csvfile: #read the csv file, row by row reader = csv.reader(csvfile) next(reader) source = [] target = [] value = [] for row in reader: source.append(int(row[0])) target.append(int(row[1])) value.append(int(row[2])) util.create_graph(G, source, target, value) degrees = G.degree(G.nodes(), None) list_degrees = list(degrees) in_degree = G.in_degree(degrees) out_degree = G.out_degree(degrees) messagebox.showinfo(title='Result', message=('the degrees of the nodes are:', degrees)) if selection == "is_g": messagebox.showinfo(title='Result', message=('the result of is_graphical:', nx.is_graphical(degrees))) elif selection == "is_d": messagebox.showinfo(title='Result', message=('the result of is_digraphical:', nx.is_digraphical( in_degree, out_degree))) elif selection == "is_m": messagebox.showinfo(title='Result', message=('the result of is_multigraphical:', nx.is_multigraphical(degrees))) elif selection == "is_p": messagebox.showinfo(title='Result', message=('the result of is_psuedographical:', nx.is_pseudographical(degrees))) elif selection == "is_hh": messagebox.showinfo( title='Result', message=( 'the result of is_havel_hakimi:', nx.is_valid_degree_sequence_havel_hakimi(list_degrees))) elif selection == "is_eg": messagebox.showinfo( title='Result', message=( 'the result of is_erdos=galli:', nx.is_valid_degree_sequence_erdos_gallai(list_degrees))) util.draw_graph(G)
def print_graph_info(G): # info about the graph number of nodes and edges print nx.info(G) # check if the graph is directed if (nx.is_directed(G)): print "Graph G is directed " else: print "Graph G isn't directed " # check if the graph is multigraph if (nx.is_multigraphical(G)): print "Graph G is multigraph" else: print "Graph G isn't multigraph" # number of self nodes in graph G print "Number of self loops in the graph: " + str( nx.number_of_selfloops(G))
def test_multi_sequence(): # Test nongraphical multi sequence seq = [1000, 3, 3, 3, 3, 2, 2, 2, 1, 1] assert not nx.is_multigraphical(seq) # Test small graphical multi sequence seq = [6, 5, 4, 4, 2, 1, 1, 1] assert nx.is_multigraphical(seq) # Test for negative integer in sequence seq = [6, 5, 4, -4, 2, 1, 1, 1] assert not nx.is_multigraphical(seq) # Test for sequence with odd sum seq = [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4] assert not nx.is_multigraphical(seq) # Test for noninteger seq = [1, 1, 1.1, 1] assert not nx.is_multigraphical(seq) seq = [1, 1, "rer", 1] assert not nx.is_multigraphical(seq)