Libraries#

raphtory.export.to_networkx(graph, explode_edges=False, include_node_properties=True, include_edge_properties=True, include_update_history=True, include_property_histories=True)[source]#

Returns a graph with NetworkX.

Note

Network X is a required dependency. If you intend to use this function make sure that you install Network X with pip install networkx

Parameters:
  • graph (Graph) – A Raphtory graph.

  • explode_edges (bool) – A boolean that is set to True if you want to explode the edges in the graph. By default this is set to False.

  • include_node_properties (bool) – A boolean that is set to True if you want to include the node properties in the graph. By default this is set to True.

  • include_edge_properties (bool) – A boolean that is set to True if you want to include the edge properties in the graph. By default this is set to True.

  • include_update_history (bool) – A boolean that is set to True if you want to include the update histories in the graph. By default this is set to True.

  • include_property_histories (bool) – A boolean that is set to True if you want to include the histories in the graph. By default this is set to True.

Returns:

A Networkx MultiDiGraph.

raphtory.export.to_pyvis(graph, explode_edges=False, edge_color='#000000', shape=None, node_image=None, edge_weight=None, edge_label=None, colour_nodes_by_type=False, type_property='type', notebook=True, **kwargs)[source]#

Draw a graph with Pyvis.

Note

Pyvis is a required dependency. If you intend to use this function make sure that you install Pyvis with pip install pyvis

Parameters:
  • graph – A Raphtory graph.

  • explode_edges – A boolean that is set to True if you want to explode the edges in the graph. By default this is set to False.

  • edge_color (str) – A string defining the colour of the edges in the graph. By default #000000 (black) is set.

  • shape (str) – An optional string defining what the node looks like.

There are two types of nodes. One type has the label inside of it and the other type has the label underneath it. The types with the label inside of it are: ellipse, circle, database, box, text. The ones with the label outside of it are: image, circularImage, diamond, dot, star, triangle, triangleDown, square and icon. By default "dot" is set. :param str node_image: An optional string defining the url of a custom node image. By default an image of a circle is set. :param str edge_weight: An optional string defining the name of the property where edge weight is set on your Raphtory graph. By default 1 is set. :param str edge_label: An optional string defining the name of the property where edge label is set on your Raphtory graph. By default, an empty string as the label is set. :param bool notebook: A boolean that is set to True if using jupyter notebook. By default this is set to True. :param kwargs: Additional keyword arguments that are passed to the pyvis Network class.

Returns:

A pyvis network

For Example:

from raphtory import Graph
from raphtory import export

g = Graph()
g.add_node(1, src, properties={"image": "image.png"})
g.add_edge(1, 1, 2, {"title": "edge", "weight": 1})
g.add_edge(1, 2, 1, {"title": "edge", "weight": 3})

export.to_pyvis(graph=g, edge_color="#FF0000", edge_weight= "weight", shape="image", node_image="image", edge_label="title")