question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

from_networkx enhancement

See original GitHub issue

From now on, we recommend using our discussion forum (https://github.com/rusty1s/pytorch_geometric/discussions) for proposing new features.

🚀 Feature

My proposal is to modify the from_networkx method to incorporate the option of creating data.x on the fly from node features (and similarly from edge features)

Motivation

The current from_networkx method does not convert the nodes features into property x (that is, data.x). I think enhancing this would be particularly useful for hand-crafted graph datasets that are saved and loaded using networkx methods.

Additional context

Some implementation details worth discussing:

  • One idea is to leave numerical features as they are, and one-hot encode categorical ones. Is the one-hot encoding needed or should each feature contain at most one item? It may be worth the flexibility, we could for example one-hot encode the node feature values that are lists, and just convert to numbers the rest.
  • Perhaps we should allow the user to define a dictionary of node features and possible values to allow coherent numericalization of many graphs if they form a “dataset” (not a Pytorch Geometric dataset, just a normal list of graphs)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rusty1scommented, Jul 30, 2021

I think we should ignore that for now, and extend functionality in later PRs if that’s okay for you.

1reaction
rusty1scommented, Jul 30, 2021

One possible interface:

def from_networkx(G, group_node_attrs=['attr1', 'attr2', ...], group_edge_attrs=['attr3', 'attr4', ...]):
    pass

where attributes in group_node_attrs and group_edge_attrs get grouped/merged/concatenated into x and edge_attr, respectively. WDYT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dgl.from_networkx — DGL 0.9.1post1 documentation
Create a graph from a NetworkX graph and return. Note. Creating a DGLGraph from a NetworkX graph is not fast especially for large...
Read more >
StellarGraph.from_networkx(node_features=...) could ... - GitHub
Description In #1047, @ntrpnr has a heterogeneous graph with 5 node types (tenant user process session computer).
Read more >
complete_to_chordal_graph — NetworkX 2.8.8 documentation
There are different approaches to calculate the chordal enhancement of a graph. The algorithm used here is called MCS-M and gives at least...
Read more >
rustworkx for NetworkX users - Qiskit
This is an introductory guide for existing NetworkX users on how to use rustworkx, how it differs from NetworkX, and key differences to...
Read more >
Python NetworkX for Graph Optimization Tutorial - DataCamp
... functionality may be removed from NetworkX or only available as an add-on package. ... it does unlock enhanced quality and control over...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found