Skip to content

Failed to retrieve attributes of the nodes, edges and a graph to be displayed with Graphviz utility (migrated from Trac #610) #601

Closed

Description

@networkx-trac

Original ticket https://networkx.lanl.gov/trac/ticket/610
Reported 2011-07-28 by al_boi22, assigned to @hagberg.

Dear team,

I used the NetworkX package to simulate a network of the applications (Thank you for the nice package!). I found an issue, when I tried to display the graph and the attributes of the nodes and edges with Graphviz package.

Technically, it does not matter what package I used for visualization, because you can see the bug if you build a graph, add some attributes to the graph, nodes, edges and use 'write_dot' function to save the graph data in a readable format. I was not able to see any attributes, which I added earlier.

This bug is related to the following lines in 'to_pydot(...) function of 'networkx-1.5\networkx\drawing\nx_pydot.py' file:

'''
try:
#P.obj_dict['attributes'].update(N.graph.get('graph',{}))
P.obj_dict['attributes'].update(getattr(N,'graph',{}))
except:
pass

try:
    #P.obj_dict['nodes']['node'][0]['attributes'].update(N.graph.get('node',{}))
    P.obj_dict['nodes']['node'][0]['attributes'].update(getattr(N,'node',{}))
except:
    pass

try:
    #P.obj_dict['nodes']['edge'][0]['attributes'].update(N.graph.get('edge',{}))
    P.obj_dict['nodes']['edge'][0]['attributes'].update(getattr(N,'edge',{}))
except:
    pass

'''

The commented lines are the ones, presented in the current version of the code. The following lines fix this bug. I believe, the original code was trying to retrieve the attributes of the attributes with the same name (for example, it was trying to find a "graph" attribute in the list of the "N.graph" attributes.

The updated version of the code works as expected.

Please, shoot me a line if you decide to update the code and move it to "production" version. I would like other developers to get the updated version of the code from your site.

Sincerely,

Alex.

Activity

  1. networkx-trac commented on Jul 20, 2012

    @networkx-trac
    Author

    Comment in Trac by Aric Hagberg <aric.hagberg, 2011-07-28

    In [10b0797/networkx]:
    '''
    #!CommitTicketReference repository="networkx" revision="10b0797f9fb615eabe7fbba18c8e5c777c1c01c3"
    Update pydot interface to use newer attribute handling style.
    Addresses #610
    '''

  2. networkx-trac commented on Jul 20, 2012

    @networkx-trac
    Author

    Comment in Trac by @hagberg, 2011-07-28

    You are right that the default attributes are not working correctly. I updated the code to use the more current style of pydot attribute handling. Can you test it to make sure that works correctly?

  3. networkx-trac commented on Jul 20, 2012

    @networkx-trac
    Author

    Comment in Trac by Aric Hagberg <aric.hagberg, 2011-07-31

    In [fb34850/networkx]:
    '''
    #!CommitTicketReference repository="networkx" revision="fb34850c5a12a90519c8bba81dafe8382c82dc46"
    Stringify graph name for pydot. Catch missing default attributes since pydot adds blank lines in the dot file otherwise.
    Addresses #610
    '''

  4. networkx-trac commented on Jul 20, 2012

    @networkx-trac
    Author

    Comment in Trac by @hagberg, 2011-07-31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions