Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Native serialization to GraphViz DOT
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Андрей Парамонов  
View profile   Translate to Translated (View Original)
 More options Aug 24 2012, 7:51 am
From: Андрей Парамонов <cmr.p...@gmail.com>
Date: Fri, 24 Aug 2012 04:51:20 -0700 (PDT)
Local: Fri, Aug 24 2012 7:51 am
Subject: Native serialization to GraphViz DOT

Currently NetworkX uses PyGraphViz or PyDot to read/write graphs in DOT
format. However, both options suffer from fatal drawbacks:
1) PyGraphViz is very hard/impossible to install on MS Windows.
2) PyDot requires too much memory (for some 5000 nodes/100000 edges
digraph, PyDot did consume 2GB and died).

Is it possible that NetworkX implements it's own, fast and efficient DOT
serialization procedures? The complete DOT file format specification it
probably not trivial, but for me naive readdot/writedot (see below) did
work surprisingly well. I believe a little less naive version would suffice
most users working with large graphs.

What do you think?
Andrey Paramonov

def readdot(dotfile):
    """A (very) naive GraphViz DOT file reader.
    dotfile: file-like object,
    returns networkx.DiGraph."""

    def parseattrs(line):
        if line:
            attrs = OrderedDict()
            for rec in line.split(', '):
                (key, value) = rec.split('=')
                attrs[key] = value
            return attrs
        else:
            return

    head = re.compile(r'strict digraph ("?)([^"]+)(\1) {$')
    node = re.compile(r'([^-]+?)( \[(.+)\])?;$')
    edge = re.compile(r'([^-]+?)->([^-]+?)( \[(.+)\])?;$')
    foot = re.compile(r'}')
    for line in dotfile.readlines():
        m = head.match(line)
        if m:
            graph = nx.DiGraph(name = m.group(2))
        m = node.match(line)
        if m:
            graph.add_node(m.group(1), parseattrs(m.group(3)))
        m = edge.match(line)
        if m:
            graph.add_edge(m.group(1), m.group(2), parseattrs(m.group(4)))
        m = foot.match(line)
        if m:
            return graph

def writedot(graph, dotfile):
    """A (very) naive GraphViz DOT file writer.
    graph: networkx.DiGraph,
    dotfile: file-like object."""

    def writerec(rec, attrs):
        dotfile.write(rec)
        if attrs:
            dotfile.write(' [' + ', '.join('='.join([key, value])
                                           for key, value in
attrs.iteritems()) + ']')
        dotfile.write(';\n')

    dotfile.write('strict digraph "' + graph.name + '" {\n')
    for node, attrs in graph.nodes(data = True):
        writerec(node, attrs)
    for u, v, attrs in graph.edges(data = True):
        writerec('->'.join([u, v]), attrs)
    dotfile.write('}\n')


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aric Hagberg  
View profile   Translate to Translated (View Original)
 More options Aug 24 2012, 11:10 am
From: Aric Hagberg <aric.hagb...@gmail.com>
Date: Fri, 24 Aug 2012 09:10:16 -0600
Local: Fri, Aug 24 2012 11:10 am
Subject: Re: [networkx-discuss] Native serialization to GraphViz DOT
Hi Андрей,

On Fri, Aug 24, 2012 at 5:51 AM, Андрей Парамонов <cmr.p...@gmail.com> wrote:
> Currently NetworkX uses PyGraphViz or PyDot to read/write graphs in DOT
> format. However, both options suffer from fatal drawbacks:
> 1) PyGraphViz is very hard/impossible to install on MS Windows.
> 2) PyDot requires too much memory (for some 5000 nodes/100000 edges digraph,
> PyDot did consume 2GB and died).

> Is it possible that NetworkX implements it's own, fast and efficient DOT
> serialization procedures? The complete DOT file format specification it
> probably not trivial, but for me naive readdot/writedot (see below) did work
> surprisingly well. I believe a little less naive version would suffice most
> users working with large graphs.

> What do you think?

I'm interested in adding something like that.  I didn't realize that
PyDot didn't work will for this.

But we should be very clear that it isn't a full-featured
implementation of the dot language specification.  Maybe we can, for
example, call the functions read_simple_dot() and write_simple_dot()?

Could you open an issue on our Github site at
https://github.com/networkx/networkx/issues ?
That is the best way for us to keep track of new feature requests and code.

Aric


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aric Hagberg  
View profile   Translate to Translated (View Original)
 More options Aug 24 2012, 11:18 am
From: Aric Hagberg <aric.hagb...@gmail.com>
Date: Fri, 24 Aug 2012 09:18:21 -0600
Local: Fri, Aug 24 2012 11:18 am
Subject: Re: [networkx-discuss] Native serialization to GraphViz DOT
Hi Андрей,

On Fri, Aug 24, 2012 at 5:51 AM, Андрей Парамонов <cmr.p...@gmail.com> wrote:
> Currently NetworkX uses PyGraphViz or PyDot to read/write graphs in DOT
> format. However, both options suffer from fatal drawbacks:
> 1) PyGraphViz is very hard/impossible to install on MS Windows.
> 2) PyDot requires too much memory (for some 5000 nodes/100000 edges digraph,
> PyDot did consume 2GB and died).

> Is it possible that NetworkX implements it's own, fast and efficient DOT
> serialization procedures? The complete DOT file format specification it
> probably not trivial, but for me naive readdot/writedot (see below) did work
> surprisingly well. I believe a little less naive version would suffice most
> users working with large graphs.

> What do you think?

I'm interested in adding something like that.  I didn't realize that
PyDot didn't work well for this.

But we should be very clear that it isn't a full-featured
implementation of the dot language specification.  Maybe we can, for
example, call the functions read_simple_dot() and write_simple_dot()?

Could you open an issue on our Github site at
https://github.com/networkx/networkx/issues ?
That is the best way for us to keep track of new feature requests and code.

Aric


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Андрей Парамонов  
View profile   Translate to Translated (View Original)
 More options Aug 27 2012, 2:48 pm
From: Андрей Парамонов <cmr.p...@gmail.com>
Date: Mon, 27 Aug 2012 11:48:48 -0700 (PDT)
Local: Mon, Aug 27 2012 2:48 pm
Subject: Re: [networkx-discuss] Native serialization to GraphViz DOT

пятница, 24 августа 2012 г., 19:10:16 UTC+4 пользователь Aric Hagberg
написал:

> I'm interested in adding something like that.  I didn't realize that
> PyDot didn't work will for this.

> But we should be very clear that it isn't a full-featured
> implementation of the dot language specification.  Maybe we can, for
> example, call the functions read_simple_dot() and write_simple_dot()?

> Could you open an issue on our Github site at
> https://github.com/networkx/networkx/issues ?
> That is the best way for us to keep track of new feature requests and code.

Done:
https://github.com/networkx/networkx/issues/757

Best wishes,
Andrey Paramonov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »