paulgirard / pygexf Goto Github PK
View Code? Open in Web Editor NEWa python library to generate gexf file format
License: Other
a python library to generate gexf file format
License: Other
It would be nice to be able to set the viz settings (in particular, the node location) for a given node. I'd love to implement this.
With the current inner working the gexf file is present two times in memory, one time as a gexf class objects another time as lxml.etree.Element
. This can be a performance problem for both import and export.
I think that with lxml custom Element classes we can improve the situation. What do you think? Are you interested in this change?
The current API requires a lot of method parameters (Gexf
constructor, Gexf.addNode
, Gexf.addEdge
) my proposition is to separate required parameters which will still be set via parameters and optional parameters which will be set by setting properties.
I understand that this is a rather cosmetic change. Also I'd like to deprecate old methods to superseed them with pep8_compliant_method_names
. This will make, I hope, the library more easier to the mind.
The git seems to support python3, however the latest release does not.
There are a lot of people downstream that would like a static release version that supports python3 as this is needed for applications, including a package I maintain in Arch's AUR, and that manjaro has contacted me about support.
All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters
graph.addNode("0", "**")
I wrote a little script that uses pygexf and wanted to use the canonical unixism of redirecting the stdout to a file or program. But this is not possible as the gexf that is produced when gexf.write(sys.stdout) is called, includes the stats banner. The stats printing should go to stderr or be optional to print out. Maybe add a stats=True/False argument to the Gexf() call?
Thanks for the very useful library.
Graph supports start end end parameters, nonetheless the Gexf.addGraph does not accept those parameters.
I didn't find any way in the code to declare a timetype value for dynamic graphs (the current spec now calls it "timeformat"). Please add something like "Gexf.addGraph(type,mode,label,timetype)". See also http://gexf.net/format/dynamics.html and http://gexf.net/1.2draft/gexf-12draft-primer.pdf page 15.
I ran the demo:
from gexf import Gexf
test helloworld.gexf
gexf = Gexf("Paul Girard","A hello world! file")
graph=gexf.addGraph("directed","static","a hello world graph")
graph.addNode("0","hello")
graph.addNode("1","World")
graph.addEdge("0","0","1")
output_file=open("hellowrld.gexf","w")
gexf.write(output_file)
but I built with python3, I got:
TypeError: write() argument must be str, not bytes
even though I know that the source code is telling us:
def write(self, file, print_stat=True):
file.write(etree.tostring(self.getXML(), pretty_print=True, encoding='utf-8', xml_declaration=True))
if print_stat is True:
self.print_stat()
what's wrong?
As in title, you should give developers ability to set all viz attributes of a gexf, in addition to rgb colors:
It is to me not clear how to add an attribute to a node or an edge using pygexf.
If I try this:
graph.edges[edge_id].addAttribute(id=attr_id, value=something)
I get:
Traceback (most recent call last): File "gexf.py", line 43, in <module> graph.edges[edge_id].addAttribute(id=attr_id, value=something) File "/usr/local/lib/python2.7/dist-packages/pygexf-0.2.2-py2.7.egg/gexf/_gexf.py", line 646, in addAttribute self._attributes.append(makeAttributeInstance(self,"node",id,value,start,end,startopen,endopen)) NameError: global name 'makeAttributeInstance' is not defined
What is the recommended way of adding attributes to nodes or edges?
I am using latest git by the way.
Hi,
I made the first attempt at a conversion, see ticket:
https://networkx.lanl.gov/trac/ticket/411
I generate a gexf with networkx and the format is slightly different, if doesn't generate additional info for every node, can this library be useful?
http://gexf.net/format/history.html <-- there have been some changes, especially in the (in this library nonexisting?) handling of the timetype/timeformat field.
Since I'd like to use exactly that, please take a look at this library again and update it to Version 1.2draft (maybe optional).
_gexf.py in line 480 should be modified from
self.spells = spells
to code like in line 633
self.spells = Spells(spells)
when I save gexf file using write() function just like this:
output_file=open(".\data.gexf","w")
gexf.write(output_file)
program report an error:
write() argument must be str, not bytes
how can I fix it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.