raphtory

Raphtory graph analytics library

class raphtory.Graph

Bases: GraphView

A temporal graph.

__new__(**kwargs)
add_edge(timestamp, src, dst, properties=Ellipsis, layer=Ellipsis)

Adds a new edge with the given source and destination vertices and properties to the graph.

Parameters
  • timestamp (int) – The timestamp of the edge.

  • src (str or int) – The id of the source vertex.

  • dst (str or int) – The id of the destination vertex.

  • properties (dict) – The properties of the edge, as a dict of string and properties

  • layer (str) – The layer of the edge.

Returns

None

add_edge_properties(src, dst, properties, layer=Ellipsis)

Adds properties to an existing edge.

Parameters
  • src (str or int) – The id of the source vertex.

  • dst (str or int) – The id of the destination vertex.

  • properties (dict) – The properties of the edge, as a dict of string and properties

  • layer (str) – The layer of the edge.

Returns

None

add_vertex(timestamp, id, properties=Ellipsis)

Adds a new vertex with the given id and properties to the graph.

Parameters
  • timestamp (int) – The timestamp of the vertex.

  • id (str or int) – The id of the vertex.

  • properties (dict) – The properties of the vertex.

Returns

None

add_vertex_properties(id, properties)

Adds properties to an existing vertex.

Parameters
  • id (str or int) – The id of the vertex.

  • properties (dict) – The properties of the vertex.

Returns

None

at(end)

Create a view including all events until end (inclusive)

Parameters

end (int) – the end time of the window

Returns

a view including all events until end (inclusive)

default_layer()

Create a view including all the edges in the default layer

Returns

a view including all the edges in the default layer

earliest_time()

Timestamp of earliest activity in the graph

Returns

the timestamp of the earliest activity in the graph

edge(src, dst, layer=Ellipsis)

Gets the edge with the specified source and destination vertices

Parameters
  • src (str or int) – the source vertex id

  • dst (str or int) – the destination vertex id

  • layer (str) – the edge layer (optional)

Returns

the edge with the specified source and destination vertices, or None if the edge does not exist

edges()

Gets all edges in the graph

Returns

the edges in the graph

end()

Returns the default end time for perspectives over the view

Returns

the default end time for perspectives over the view

expanding(step)

Creates a WindowSet with the given step size and optional start and end times, using an expanding window.

An expanding window is a window that grows by step size at each iteration.

Parameters
  • step (int) – the size of the window

  • start (int) – the start time of the window (optional)

  • end (int) – the end time of the window (optional)

Returns

A WindowSet with the given step size and optional start and end times,

get_unique_layers()
has_edge(src, dst, layer=Ellipsis)

Returns true if the graph contains the specified edge

Parameters
  • src (str or int) – the source vertex id

  • dst (str or int) – the destination vertex id

  • layer (str) – the edge layer (optional)

Returns

true if the graph contains the specified edge, false otherwise

has_vertex(id)

Returns true if the graph contains the specified vertex

Parameters

id (str or int) – the vertex id

Returns

true if the graph contains the specified vertex, false otherwise

latest_time()

Timestamp of latest activity in the graph

Returns

the timestamp of the latest activity in the graph

layer(name)

Create a view including all the edges in the layer name

Parameters

name (str) – the name of the layer

Returns

a view including all the edges in the layer name

static load_from_file(path)

Loads a graph from the given path.

Parameters

path (str) – The path to the graph.

Returns

The loaded graph.

Return type

Graph

num_edges()

Number of edges in the graph

Returns

the number of edges in the graph

num_vertices()

Number of vertices in the graph

Returns

the number of vertices in the graph

rolling(window, step=Ellipsis)

Creates a WindowSet with the given window size and optional step, start and end times, using a rolling window.

A rolling window is a window that moves forward by step size at each iteration.

Parameters
  • window (int) – the size of the window

  • step (int) – the size of the step (optional)

  • start (int) – the start time of the window (optional)

  • end – the end time of the window (optional)

Returns

a WindowSet with the given window size and optional step, start and end times,

save_to_file(path)

Saves the graph to the given path.

Parameters

path (str) – The path to the graph.

Returns: None

start()

Returns the default start time for perspectives over the view

Returns

the default start time for perspectives over the view

vertex(id)

Gets the vertex with the specified id

Parameters

id (str or int) – the vertex id

Returns

the vertex with the specified id, or None if the vertex does not exist

window(start=Ellipsis, end=Ellipsis)

Create a view including all events between t_start (inclusive) and t_end (exclusive)

Parameters
  • start (int) – the start time of the window (optional)

  • end (int) – the end time of the window (optional)

Returns

a view including all events between t_start (inclusive) and t_end (exclusive)

vertices

Gets the vertices in the graph

Returns

the vertices in the graph