networkit.gephi

Submodules

networkit.gephi.csv module

networkit.gephi.csv.exportNodeValues(values, fpath, column_name)

This method exports node values (e.g. community information, betwenness centrality values) to a CSV file. The values can then be imported to Gephi.

Parameters:
  • values (list(float) or networkit.Partition) – Python list or Partition object that contains the values to be exported.

  • fpath (str) – The file including its path to be written to.

  • column_name (str) – Name of the column as description for the data.

networkit.gephi.pyclient module

Allow a Python script to communicate with Gephi using the Gephi Graph Streaming protocol and plugin.

class networkit.gephi.pyclient.GephiClient(url='http://127.0.0.1:8080/workspace0', autoflush=False)

Bases: JSONClient

Supporter class for GephiStreamingclient.

Creates a GephiClient, which is derived from JSONClient. The internal _send-function is changed in order to update the Gephi server.

Parameters:
  • url (str, optional) – URL of the Gephi server. Default: http://127.0.0.1:8080/workspace0

  • autoflush (bool, optional) – Indicates whether autoflush is enabled. Default: False

class networkit.gephi.pyclient.GephiFileHandler(out, **params)

Bases: JSONClient

class networkit.gephi.pyclient.JSONClient(autoflush=0, enable_timestamps=False, process_event_hook=None)

Bases: object

Supporter class for Gephiclient. Used to encapsulate data in JSON-format.

Parameters:
  • autoflush (int, optional) – Enables automatic after certain data additions. Default = 0

  • enable_timestamps (bool, optional) – Enable timestamps for data entries. Default: False

  • process_event_hook (function, optional) – Custom event hook function. Default: None

add_edge(id, source, target, directed=True, **attributes)

Add a “add edge” event to the data stream.

Parameters:
  • id (int) – Edge id.

  • source (int) – Source node id.

  • target (int) – Target node id.

  • directed (bool, optional) – Indicates whether edge is directed. Default: True

  • attributes (dict()) – Attributes, which should be associated with the edge.

add_node(id, flush=True, **attributes)

Add a “add node” event to the data stream.

Parameters:
  • id (int) – Node id.

  • flush (bool, optional) – Parameter not used.

  • attributes (**kwargs) – Attributes, which should be associated with the node.

change_edge(id, source, target, directed=True, **attributes)

Add a “change edge” event to the data stream.

Parameters:
  • id (int) – Edge id.

  • source (int) – Source node id.

  • target (int) – Target node id.

  • directed (bool, optional) – Indicates whether edge is directed. Default: True

  • attributes (dict()) – Attributes, which should be associated with the edge.

change_node(id, flush=True, **attributes)

Add a “change node” event to the data stream.

Parameters:
  • id (int) – Node id.

  • flush (bool, optional) – Parameter not used.

  • attributes (dict()) – Attributes, which should be associated with the.

clean()

Add a “clean” event to the data stream.

delete_edge(id)

Add a “delete edge” event to the data stream.

Parameters:
  • id (int) – Edge id.

  • source (int) – Source node id.

  • target (int) – Target node id.

  • directed (bool, optional) – Indicates whether edge is directed. Default: True

  • attributes (dict()) – Attributes, which should be associated with the edge.

delete_node(id)

Add a “delete node” event to the data stream.

Parameters:

id (int) – Node id.

flush()

Sends all data and clear buffer.

incrementUnflushedDumps()

Increment number of unflushed dumps. Is resetted based on the value of autoflush.

networkit.gephi.streaming module

This module provides methods to export data from NetworKit directly to Gephi using the Gephi Streaming Plugin.

class networkit.gephi.streaming.GephiStreamingClient(url='http://localhost:8080/workspace0')

Bases: object

A python singleton providing access to a running Master instance of the Gephi Streaming plugin.

Parameters:

url (str, optional) – URL of the Gephi server. Default: http://127.0.0.1:8080/workspace0

clearGraph()

Cleans the first workspace in Gephi.

exportAdditionalEdge(u, v)

Adds an edge (u,v) in an already exported graph. If the edge is already present, nothing happens. If the graph is directed, the edge goes from u to v.

Parameters:
  • u (int) – The first node.

  • v (int) – The second node.

exportCoordinates(graph, scale=1)

Exports the x and y coordinates for each node in given graph.

Parameters:
  • graph (networkit.Graph) – The input graph.

  • scale (int) – Determines the exported x and y coordinates. Using default scale=1, all node coordinates are being exported, increasing the scale decreases the number of node coordinates being exported.

exportEdgeValues(graph, values, attribute_name)

This method exports an edge attribute to gephi using the Gephi Streaming Plugin. Use exportGraph(Graph) first to export graph itself.

Parameters:
  • graph (networkit.Graph) – The input graph.

  • values (list(float) or networkit.Partition) – Python list or Partition object that contains the values to be exported.

  • attribute_name (str) – Name of the node attribute in Gephi.

exportEventStream(stream, timeStepDelay=0)

Export a given event stream of networkit.dynamics.GraphEvent to Gephi server.

Parameters:
  • stream (list(networkit.dynamics.GraphEvent)) – The input stream.

  • timeStepDelay (int, optional) – Add a delay (in ms) for every time step event. Default: 0

exportGraph(graph)

Exports the given graph to gephi. No attributes or weights are exported. Please note that only graphs with indexed edges can be exported, so edges will be indexed if neccessary.

Parameters:

graph (networkit.Graph) – The input graph.

exportNodeValues(graph, values, attribute_name)

This method exports node values (e.g. community information, betwenness centrality values) to gephi using the Gephi Streaming Plugin. Use exportGraph(Graph) first to export the graph itself.

Parameters:
  • graph (networkit.Graph) – The input graph.

  • values (list(float) or networkit.Partition) – Python list or Partition object that contains the values to be exported.

  • attribute_name (str) – Name of the node attribute in Gephi.

removeExportedEdge(u, v)

Removes an edge from an already exported graph.

Parameters:
  • u (int) – The first node.

  • v (int) – The second node.