bw2io.export.gexf#

Classes#

DatabaseSelectionToGEXF

Export a Gephi graph for a selection of activities from a database.

DatabaseToGEXF

Export a Gephi graph for a database.

Functions#

keyword_to_gephi_graph(database,Β keyword)

Export a Gephi graph for a database for all activities whose names include the string keyword.

Module Contents#

class bw2io.export.gexf.DatabaseSelectionToGEXF(database, keys)[source]#

Bases: DatabaseToGEXF

Export a Gephi graph for a selection of activities from a database.

Also includes all inputs for the filtered activities.

Parameters:
  • database (str) – Database name.

  • keys (str) – The activity keys to export.

Examples

>>> dstg = DatabaseSelectionToGEXF(database='example_db', keys=['foo', 'bar'])
data[source]#
database[source]#
filepath[source]#
id_mapping[source]#
class bw2io.export.gexf.DatabaseToGEXF(database, include_descendants=False)[source]#

Bases: object

Export a Gephi graph for a database.

Parameters:
  • database (str) – Database name.

  • include_descendants (bool, optional) – Include databases which are linked from database. (default False)

Warning

include_descendants is not yet implemented.

Raises:

NotImplemented – If include_descendants is True, as this option is not yet implemented.

export()[source]#

Export the Gephi XML file.

get_data(E)[source]#

Get the nodes and edges for the Gephi XML file.

Examples

>>> dtg = DatabaseToGEXF(database='example_db', include_descendants=False)
>>> dtg.export()
'/path/to/example_db.gexf'
>>> dtg = DatabaseToGEXF(database='example_db', include_descendants=True)
>>> dtg.get_data()
(nodes, edges)
export()[source]#

Export the Gephi XML file.

Parameters:

None

Returns:

Filepath of the created file.

Return type:

str

Examples

>>> dtg = DatabaseToGEXF(database='example_db', include_descendants=False)
>>> dtg.export()
'/path/to/example_db.gexf'
get_data(E)[source]#

Get Gephi nodes and edges.

Parameters:

E (lxml.builder.ElementMaker) – ElementMaker object for GEXF XML

Returns:

  • nodes (lxml.etree._Element) – GEXF nodes

  • edges (lxml.etree._Element) – GEXF edges

Examples

>>> dtg = DatabaseToGEXF(database='example_db', include_descendants=False)
>>> dtg.get_data(E)
(nodes, edges)
data[source]#
database[source]#
descendants = False[source]#
filepath[source]#
id_mapping[source]#
bw2io.export.gexf.keyword_to_gephi_graph(database, keyword)[source]#

Export a Gephi graph for a database for all activities whose names include the string keyword.

Parameters:
  • database (str) – Database name.

  • keyword (str) – Keyword to search for.

Returns:

The filepath of the exported file.

Return type:

str

Examples

>>> keyword_to_gephi_graph(database='example_db', keyword='foo')
'/path/to/example_db.gexf'