networkx/networkx — pull request #855 by pedros (2013-03-13 13:31:42+00:00)
Title: readwrite module for interfacing with RDF

Read and write graphs in [RDF](https://www.w3.org/RDF/) format. Requires [rdflib](https://github.com/RDFLib/rdflib). This module adds 8 new functions:

- [read_rdf](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L518)
- [from_rdfgraph](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L167)
- [write_rdf](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L540)
- [to_rdfgraph](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L460)
- [read_rgml](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L316)
- [from_rgmlgraph](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L167)
- [write_rgml](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L342)
- [to_rgmlgraph](https://github.com/pedros/networkx/blob/readwrite/rdf/networkx/readwrite/rdf.py#L258)

It can load arbitrary RDF graphs, or RGML-namespaced graphs. [RGML](https://www.cs.rpi.edu/research/groups/pb/punin/public_html/RGML/) is the RDF Graph Modeling Language, an RDF ontology for generic graphs.

For arbitrary RDF graphs, it can represent them as multiple directed labeled graphs as per the RDF specification, with terms that occur as subject/object and, later on, as a predicate, being reified multiple times. Since this is not optimal for connectivity analyses, it also recognizes that RDF graphs are, in fact, hypergraphs, and as such represents them as bipartite graphs where each node in one partition has 3 edges pointing to subject, predicate, and object nodes in the other partition.

For more information, see [Hayes, J. (2004). A graph model for RDF. Technische Universität Darmstadt](http://www.dcc.uchile.cl/~cgutierr/papers/rdfgraphmodel.pdf)

All serialization formats supported by `rdflib` are supported, currently:

- [RDF/XML](http://www.w3.org/TR/rdf-syntax-grammar/)
- [Notation 3](http://www.w3.org/TeamSubmission/n3/)
- [Turtle](http://www.w3.org/TeamSubmission/turtle/)
- [N-Triples](http://www.w3.org/TR/rdf-testcases/#ntriples)
- [Trix](https://www.hpl.hp.com/techreports/2004/HPL-2004-56)