-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are Node and Edge classes necessary? #1
Comments
If our aim is to follow the Python NetworkX, it shouldn't be. Any object can be a node; and an edge should be able to store the relation between two nodes, which could be an However, using this approach, lookup of an edge seems to become a significant burden, since, while we know While we could alternatively use |
I just went though some of the Python code, they have used a very similar approach, except they also have a separate dictionary of Node attributes. This is an unrelated feature, and can be added later as the project grows without much change to the existing implementation. |
@ajeetdsouza - Can you link the Python NetworkX's documentation and code for the Node attributes here? |
They explicitly say The basic graph code is found here. |
IMO the use of classes will help in making multigraphs and digraphs by inherent properties. |
Hmm, yes. The >>> K3 = nx.Graph([(0, 1), (1, 2), (2, 0)])
>>> G.add_node(K3)
>>> G.number_of_nodes()
3 So, let's have separate |
That use case can be resolved separately by adding methods to retrieve a list of nodes from a graph, and then calling |
Treating each node as graph can be expensive considering the number of methods it will be referenced to. Why not port the code first and then introduce changes? |
You're not treating it as a graph, you're treating it as a generic object - so you can essentially add a node of any (hashable) type. In the case mentioned by @athityakumar where you pass a graph to |
The most simplest approach that comes in mind, while thinking of representing Nodes and Edges in a Graph, is via Ruby's inbuilt
Hash
data structure.The text was updated successfully, but these errors were encountered: