Ewaryst Polch
unread,Aug 26, 2024, 3:27:12 PM8/26/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to networkx-discuss
I've been working on a problem of finding Hamiltonian path in a fairly simple network and found things that defied my understanding of what is a tournament graph. To get to the bottom of it, I condensed the code to the simplest test I could think of.
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
G = nx.DiGraph([(0, 1), (1, 2), (2, 3), (3,0)])
print (G)
print (G.edges)
print("Is G tournament ?", nx.is_tournament(G))
G.remove_edge(3,0)
print (G)
print (G.edges)
print("Is G tournament ?", nx.is_tournament(G))
G.remove_edge(2,3)
G.remove_node(3)
G.add_edge(2,0)
print (G)
print (G.edges)
print("Is G tournament ?", nx.is_tournament(G))
G.remove_edge(2,0)
G.add_node(3)
G.add_edge(2,3)
print (G)
print (G.edges)
print("Is G tournament ?", nx.is_tournament(G))
G.add_edge(3,0)
print (G)
print (G.edges)
print("Is G tournament ?", nx.is_tournament(G))
When I run it in on Python 3.9.19 with NetworkX 3.2.1 in anaconda3 environment, I get the following results:
(base) C:\My Documents\Notes>python TourTest.py
DiGraph with 4 nodes and 4 edges
[(0, 1), (1, 2), (2, 3), (3, 0)]
Is G tournament ? False
DiGraph with 4 nodes and 3 edges
[(0, 1), (1, 2), (2, 3)]
Is G tournament ? False
DiGraph with 3 nodes and 3 edges
[(0, 1), (1, 2), (2, 0)]
Is G tournament ? True
DiGraph with 4 nodes and 3 edges
[(0, 1), (1, 2), (2, 3)]
Is G tournament ? False
DiGraph with 4 nodes and 4 edges
[(0, 1), (1, 2), (2, 3), (3, 0)]
Is G tournament ? False
(base) C:\My Documents\Notes>
Please, explain to me what is wrong with this picture, as my understanding is that there must be a bug in the is_tournament() function. I have not seen any mentions of the size limitations on tournament graphs (3 nodes and edges OK, but 4 not acceptable ?)
Regards,
E.Z. Polch