PGX supports loading graphs from files using the XML-based GraphML format. Graphs already in memory may also be exported into GraphML files. For a detailed description of the XML schema, please consult the GraphML specification.
Note that PGX does not support all features of the GraphML format. Some of the limitations are:
edgedefault="undirected"
), then edge properties are not supportedport
, default
, and hyperedge
are not supportedThe example graph below consists of 3 vertices and 3 edges. Each vertex has an integer property named number
and each edge has a string property named label
.
Note that the edges are directed and that the strings for the property do not have to be put in (double) quotation marks.
<?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"> <key attr.name="number" attr.type="integer" for="node" id="number"/> <key attr.name="label" attr.type="string" for="edge" id="label"/> <graph edgedefault="directed"> <node id="1"> <data key="number">2</data> </node> <node id="2"> <data key="number">45</data> </node> <node id="3"> <data key="number">83</data> </node> <edge target="2" source="1"> <data key="label">this graph</data> </edge> <edge source="3" target="2"> <data key="label">forms a</data> </edge> <edge target="1" source="3"> <data key="label">triangle</data> </edge> </graph> </graphml>
The image below shows a visualization of this graph:
Please be aware that because of the verbose nature of XML, the GraphML format comes with a large overhead compared to other file-based graph formats. If load/store performance and file size are important factors for you, consider using a different format.