Skip to content

Python script that translates an XML network definition file into the graphml format

License

Notifications You must be signed in to change notification settings

furukama/xml2graphml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

xml2graphml is a Python script that translates XML format social
network definitions in the popular graphml format.

There are some programs that allow you to export social network
definition files (nodes and edges) in XML format. This script allows
to translate the XML output to graphml that can be processed by most
social network analysis programs.

Example:

This XML network definition example.xml:

<?xml version="1.0" standalone="yes"?>
<network>
<nodes>
<node id="first-node"><property id="frequency" value="1"/></node>
<node id="second-node"><property id="frequency" value="2"/></node>
</nodes>
<links>
<link source="first-node" target="second-node"></link>
</links>
</network>

Can be translated with the following command:

xlm2graphml.py example.xml example.graphml

Into this graphml file:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graph id="G" edgedefault="directed">
<key id="label" for="node" attr.name="label" attr.type="string"/>
<key id="frequency" for="node" attr.name="frequency" attr.type="double"/>
<key id="weight" for="edge" attr.name="weight" attr.type="double"/>
<node id="0">
<data key="label">first-node</data>
<data key="frequency">1</data>
</node>
<node id="1">
<data key="label">second-node</data>
<data key="frequency">2</data>
</node>
<edge source="0" target="1">
<data key="weight">1.0</data>
</edge>
</graph>
</graphml>

About

Python script that translates an XML network definition file into the graphml format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published