Export networks to structured and unstructured formats, for visualization.
collection | Write GraphCollection to a structured data format. |
graph | Write NetworkX graphs to structured and unstructured network file formats. |
corpora | |
matrix | Methods for writing matrices to commonly-used file formats, for external visualization and analysis. |
Write GraphCollection to a structured data format.
to_dxgmml(C, path) | Writes a GraphCollection to |
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 DataCollection, and slice it temporally using a
>>> # 4-year sliding time-window.
>>> from tethne.data import DataCollection, GraphCollection
>>> D = DataCollection(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
path : str
|
---|
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.
Parameters : | target : str
ngrams : dict
|
---|---|
Returns : | None : If all goes well. |
Raises : | ValueError : |
Write NetworkX graphs to structured and unstructured network file formats.
Many methods simply invoke equivalent methods in NetworkX.
to_gexf(graph, output_path) | Writes graph to GEXF. |
to_graphml(graph, path[, encoding, prettyprint]) | Writes graph to GraphML. |
to_sif(graph, output_path) | Generates Simple Interaction Format output file from provided graph. |
Bases: networkx.readwrite.graphml.GraphMLWriter
Methods
add_attributes(scope, xml_obj, data, default) | Appends attributes to edges or nodes. |
add_data(name, element_type, value[, scope, ...]) | Make a data element for an edge or a node. |
add_edges(G, graph_element) | |
add_graph_element(G) | Serialize graph G in GraphML to the stream. |
add_graphs(graph_list) | Add many graphs to this GraphML document. |
add_nodes(G, graph_element) | |
dump(stream) | |
get_key(name, attr_type, scope, default) | |
indent(elem[, level]) |
Writes graph to GEXF.
Uses the NetworkX method write_gexf.
Parameters : | graph : networkx.Graph
output_path : str
|
---|
Writes graph to GraphML.
Uses the NetworkX method write_graphml.
Parameters : | graph : networkx.Graph
output_path : str
|
---|
Generates Simple Interaction Format output file from provided graph.
The SIF specification is described here.
to_sif() will generate a .sif file describing the network, and a few .eda and .noa files containing edge and node attributes, respectively. These are equivalent to tab-delimited tables, and can be imported as such in Cytoscape 3.0.
Parameters : | graph : networkx.Graph
output_path : str
|
---|
Methods for writing matrices to commonly-used file formats, for external visualization and analysis. Not yet implemented.