SciPy

tethne.writers.collection module

Write GraphCollection to a structured data format.

to_dxgmml(C, path) Writes a GraphCollection to `dynamic XGMML.
tethne.writers.collection.to_dxgmml(C, path)[source]

Writes a GraphCollection to dynamic XGMML..

Dynamic XGMML is a schema for describing dynamic networks in Cytoscape 3.0. This method assumes that Graph indices are orderable points in time (e.g. years). The “start” and “end” of each node and edge are determined by periods of consecutive appearance in the GraphCollection . Node and edge attributes are defined for each Graph. in the GraphCollection.

For example, to build and visualize an evolving co-citation network:

>>> # Load some data.
>>> import tethne.readers as rd
>>> papers = rd.wos.read(datapath)

>>> # Build a Corpus, and slice it temporally using a
>>> #  4-year sliding time-window.
>>> from tethne.data import Corpus, GraphCollection
>>> D = Corpus(papers)
>>> D.slice('date', 'time_window', window_size=4)

>>> # Generate a GraphCollection of co-citation graphs.
>>> from tethne.builders import paperCollectionBuilder
>>> builder = paperCollectionBuilder(D)
>>> C = builder.build('date', 'cocitation', threshold=2)

>>> # Write the GraphCollection as a dynamic network.
>>> import tethne.writers as wr
>>> wr.collection.to_dxgmml(C, "/path/to/network.xgmml")
Parameters:

C : GraphCollection

The GraphCollection to be written to XGMML.

path : str

Path to file to be written. Will be created/overwritten.

Raises:

AttributeError

C must be a tethne.classes.GraphCollection.

Notes

Period start and end dates in this method are inclusive, whereas XGMML end dates are exclusive. Hence +1 is added to all end dates when writing XGMML.