Skip to content
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

Empty GraphML attribute is not shown with networkx #7291

Closed
FHantke opened this issue Feb 13, 2024 · 1 comment · Fixed by #7319
Closed

Empty GraphML attribute is not shown with networkx #7291

FHantke opened this issue Feb 13, 2024 · 1 comment · Fixed by #7319

Comments

@FHantke
Copy link

FHantke commented Feb 13, 2024

Current Behavior

Currently, networkx does not show (GraphML) attributes that are empty.

Here is little example.

<?xml version='1.0' encoding='utf-8'?>
<graphml>
  <key id="d1" for="node" attr.name="foo" attr.type="string"/>
  <key id="d2" for="node" attr.name="bar" attr.type="string"/>
  <graph>
    <node id="0">
      <data key="d1">aaa</data>
      <data key="d2">bbb</data>
    </node>

    <node id="1">
      <data key="d1">ccc</data>
      <data key="d2"></data>
    </node>
  </graph>
</graphml>

If I load the file, node 0 shows both attributes while node 1 only shows the attribute foo.

G = nx.read_graphml("example.graphml")
G.nodes().get('0')
# {'foo': 'aaa', 'bar': 'bbb'}
G.nodes().get('1')
# {'foo': 'ccc'}

Expected Behavior

I would expect that node 1 shows attribute bar containing an empty string.

Environment

Python version: Python 3.11.6
NetworkX version: networkx==3.2.1

Additional context

This bug appeared during an analysis of the Brave pagegraph, see here.

salym added a commit to salym/networkx that referenced this issue Feb 29, 2024
Fixes  networkx#7291

networkx does not parse GraphML attributes that are empty.
This fix will create the attribute with an empty string.
salym added a commit to salym/networkx that referenced this issue Feb 29, 2024
Fixes  networkx#7291

networkx does not parse GraphML attributes that are empty.
This fix will create the attribute with an empty string.
MridulS pushed a commit that referenced this issue Mar 1, 2024
* Empty GraphML attribute is not parsed (main branche)

Fixes  #7291

networkx does not parse GraphML attributes that are empty.
This fix will create the attribute with an empty string.

* added test test_graphml.py

* minor changes (lint)
@FHantke
Copy link
Author

FHantke commented Mar 1, 2024

Thank you!

cvanelteren pushed a commit to cvanelteren/networkx that referenced this issue Apr 22, 2024
* Empty GraphML attribute is not parsed (main branche)

Fixes  networkx#7291

networkx does not parse GraphML attributes that are empty.
This fix will create the attribute with an empty string.

* added test test_graphml.py

* minor changes (lint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants