GraphView

Graph view is a read-only version of a graph at a certain point in time.

Methods

MethodDescription
afterCreate a view of the GraphView including all events after start (exclusive).
atCreate a view of the GraphView including all events at time.
beforeCreate a view of the GraphView including all events before end (exclusive).
cache_viewApplies the filters to the graph and retains the node ids and the edge ids
count_edgesNumber of edges in the graph
count_nodesNumber of nodes in the graph
count_temporal_edgesNumber of edges in the graph
default_layerReturn a view of GraphView containing only the default edge layer
edgeGets the edge with the specified source and destination nodes
exclude_layerReturn a view of GraphView containing all layers except the excluded name
exclude_layersReturn a view of GraphView containing all layers except the excluded names
exclude_nodesReturns a subgraph given a set of nodes that are excluded from the subgraph
exclude_valid_layerReturn a view of GraphView containing all layers except the excluded name
exclude_valid_layersReturn a view of GraphView containing all layers except the excluded names
expandingCreates a WindowSet with the given step size using an expanding window.
filterReturn a filtered view that only includes nodes and edges that satisfy the filter
find_edgesGet the edges that match the properties name and value
find_nodesGet the nodes that match the properties name and value
get_index_specGet index spec
has_edgeReturns true if the graph contains the specified edge
has_layerCheck if GraphView has the layer "name"
has_nodeReturns true if the graph contains the specified node
latestCreate a view of the GraphView including all events at the latest time.
layerReturn a view of GraphView containing the layer "name"
layersReturn a view of GraphView containing all layers names
materializeReturns a 'materialized' clone of the graph view - i.e. a new graph with a copy of the data seen within the view instead of just a mask over the original graph
nodeGets the node with the specified id
rollingCreates a WindowSet with the given window size and optional step using a rolling window.
search_edgesSearches for edges which match the given filter expression. This uses Tantivy's exact search.
search_nodesSearches for nodes which match the given filter expression. This uses Tantivy's exact search.
shrink_endSet the end of the window to the smaller of end and self.end()
shrink_startSet the start of the window to the larger of start and self.start()
shrink_windowShrink both the start and end of the window (same as calling shrink_start followed by shrink_end but more efficient)
snapshot_atCreate a view of the GraphView including all events that have not been explicitly deleted at time.
snapshot_latestCreate a view of the GraphView including all events that have not been explicitly deleted at the latest time.
subgraphReturns a subgraph given a set of nodes
subgraph_node_typesReturns a subgraph filtered by node types given a set of node types
to_networkxReturns a graph with NetworkX.
to_pyvisDraw a graph with PyVis.
validReturn a view of the graph that only includes valid edges
valid_layersReturn a view of GraphView containing all layers names
vectoriseCreate a VectorisedGraph from the current graph.
windowCreate a view of the GraphView including all events between start (inclusive) and end (exclusive)

Properties

PropertyDescription
earliest_timeTime entry of the earliest activity in the graph
edgesGets all edges in the graph
endGets the latest time that this GraphView is valid.
latest_timeTime entry of the latest activity in the graph
metadataGet all graph metadata
nodesGets the nodes in the graph
propertiesGet all graph properties
startGets the start time for rolling and expanding windows for this GraphView
unique_layersReturn all the layer ids in the graph
window_sizeGet the window size (difference between start and end) for this GraphView.

Method Details

after

Signature: after(start)

Create a view of the GraphView including all events after start (exclusive).

Parameters

NameTypeDefaultDescription
startTimeInput-The start time of the window.

Returns

TypeDescription
GraphView

at

Signature: at(time)

Create a view of the GraphView including all events at time.

Parameters

NameTypeDefaultDescription
timeTimeInput-The time of the window.

Returns

TypeDescription
GraphView

before

Signature: before(end)

Create a view of the GraphView including all events before end (exclusive).

Parameters

NameTypeDefaultDescription
endTimeInput-The end time of the window.

Returns

TypeDescription
GraphView

cache_view

Applies the filters to the graph and retains the node ids and the edge ids in the graph that satisfy the filters creates bitsets per layer for nodes and edges

Returns

TypeDescription
GraphViewReturns the masked graph

count_edges

Number of edges in the graph

Returns

TypeDescription
intthe number of edges in the graph

count_nodes

Number of nodes in the graph

Returns

TypeDescription
intthe number of nodes in the graph

count_temporal_edges

Number of edges in the graph

Returns

TypeDescription
intthe number of temporal edges in the graph

default_layer

Return a view of GraphView containing only the default edge layer

Returns

TypeDescription
GraphViewThe layered view

edge

Signature: edge(src, dst)

Gets the edge with the specified source and destination nodes

Parameters

NameTypeDefaultDescription
srcNodeInput-the source node id
dstNodeInput-the destination node id

Returns

TypeDescription
Edge, optionalthe edge with the specified source and destination nodes, or None if the edge does not exist

exclude_layer

Signature: exclude_layer(name)

Return a view of GraphView containing all layers except the excluded name Errors if any of the layers do not exist.

Parameters

NameTypeDefaultDescription
namestr-layer name that is excluded for the new view

Returns

TypeDescription
GraphViewThe layered view

exclude_layers

Signature: exclude_layers(names)

Return a view of GraphView containing all layers except the excluded names Errors if any of the layers do not exist.

Parameters

NameTypeDefaultDescription
nameslist[str]-list of layer names that are excluded for the new view

Returns

TypeDescription
GraphViewThe layered view

exclude_nodes

Signature: exclude_nodes(nodes)

Returns a subgraph given a set of nodes that are excluded from the subgraph

Parameters

NameTypeDefaultDescription
nodeslist[NodeInput]-set of nodes

Returns

TypeDescription
GraphViewReturns the subgraph

exclude_valid_layer

Signature: exclude_valid_layer(name)

Return a view of GraphView containing all layers except the excluded name

Parameters

NameTypeDefaultDescription
namestr-layer name that is excluded for the new view

Returns

TypeDescription
GraphViewThe layered view

exclude_valid_layers

Signature: exclude_valid_layers(names)

Return a view of GraphView containing all layers except the excluded names

Parameters

NameTypeDefaultDescription
nameslist[str]-list of layer names that are excluded for the new view

Returns

TypeDescription
GraphViewThe layered view

expanding

Signature: expanding(step, alignment_unit=None)

Creates a WindowSet with the given step size using an expanding window.

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

Parameters

NameTypeDefaultDescription
stepint | str-The step size of the window.
alignment_unitstr | None, optionalNoneIf no alignment_unit is passed, aligns the start of the first window to the smallest unit of time passed to step. For example, if the step is "1 month and 1 day", the windows will be aligned on days (00:00:00 to 23:59:59). If set to "unaligned", the first window will begin at the first time event. If any other alignment unit is passed, the windows will be aligned to that unit. alignment_unit defaults to None.

Returns

TypeDescription
WindowSetA WindowSet object.

filter

Signature: filter(filter)

Return a filtered view that only includes nodes and edges that satisfy the filter

Parameters

NameTypeDefaultDescription
filterfilter.FilterExpr-The filter to apply to the nodes and edges.

Returns

TypeDescription
GraphViewThe filtered view

find_edges

Signature: find_edges(properties_dict)

Get the edges that match the properties name and value

Parameters

NameTypeDefaultDescription
properties_dictdict[str, PropValue]-the properties name and value

Returns

TypeDescription
list[Edge]the edges that match the properties name and value

find_nodes

Signature: find_nodes(properties_dict)

Get the nodes that match the properties name and value

Parameters

NameTypeDefaultDescription
properties_dictdict[str, PropValue]-the properties name and value

Returns

TypeDescription
list[Node]the nodes that match the properties name and value

get_index_spec

Get index spec

Returns

TypeDescription
IndexSpec

has_edge

Signature: has_edge(src, dst)

Returns true if the graph contains the specified edge

Parameters

NameTypeDefaultDescription
srcNodeInput-the source node id
dstNodeInput-the destination node id

Returns

TypeDescription
booltrue if the graph contains the specified edge, false otherwise

has_layer

Signature: has_layer(name)

Check if GraphView has the layer "name"

Parameters

NameTypeDefaultDescription
namestr-the name of the layer to check

Returns

TypeDescription
bool

has_node

Signature: has_node(id)

Returns true if the graph contains the specified node

Parameters

NameTypeDefaultDescription
idNodeInput-the node id

Returns

TypeDescription
booltrue if the graph contains the specified node, false otherwise

latest

Create a view of the GraphView including all events at the latest time.

Returns

TypeDescription
GraphView

layer

Signature: layer(name)

Return a view of GraphView containing the layer "name" Errors if the layer does not exist

Parameters

NameTypeDefaultDescription
namestr-then name of the layer.

Returns

TypeDescription
GraphViewThe layered view

layers

Signature: layers(names)

Return a view of GraphView containing all layers names Errors if any of the layers do not exist.

Parameters

NameTypeDefaultDescription
nameslist[str]-list of layer names for the new view

Returns

TypeDescription
GraphViewThe layered view

materialize

Returns a 'materialized' clone of the graph view - i.e. a new graph with a copy of the data seen within the view instead of just a mask over the original graph

Returns

TypeDescription
GraphViewReturns a graph clone

node

Signature: node(id)

Gets the node with the specified id

Parameters

NameTypeDefaultDescription
idNodeInput-the node id

Returns

TypeDescription
Node, optionalthe node with the specified id, or None if the node does not exist

rolling

Signature: rolling(window, step=None, alignment_unit=None)

Creates a WindowSet with the given window size and optional step using a rolling window. If alignment_unit is not "unaligned" and a step larger than window is provided, some time entries may appear before the start of the first window and/or after the end of the last window (i.e. not included in any window).

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

Parameters

NameTypeDefaultDescription
windowint | str-The size of the window.
stepint | str | None, optionalNoneThe step size of the window. step defaults to window.
alignment_unitstr | None, optionalNoneIf no alignment_unit is passed, aligns the start of the first window to the smallest unit of time passed to step (or window if no step is passed). For example, if the step is "1 month and 1 day", the first window will begin at the start of the day of the first time event. If set to "unaligned", the first window will begin at the first time event. If any other alignment unit is passed, the windows will be aligned to that unit. alignment_unit defaults to None.

Returns

TypeDescription
WindowSetA WindowSet object.

search_edges

Signature: search_edges(filter, limit=25, offset=0)

Searches for edges which match the given filter expression. This uses Tantivy's exact search.

Parameters

NameTypeDefaultDescription
limitint, optional25The maximum number of results to return. Defaults to 25.
offsetint, optional0The number of results to skip. This is useful for pagination. Defaults to 0.
filterAny-

Returns

TypeDescription
list[Edge]A list of edges which match the filter expression. The list will be empty if no edges match the query.

search_nodes

Signature: search_nodes(filter, limit=25, offset=0)

Searches for nodes which match the given filter expression. This uses Tantivy's exact search.

Parameters

NameTypeDefaultDescription
limitint, optional25The maximum number of results to return. Defaults to 25.
offsetint, optional0The number of results to skip. This is useful for pagination. Defaults to 0.
filterAny-

Returns

TypeDescription
list[Node]A list of nodes which match the filter expression. The list will be empty if no nodes match.

shrink_end

Signature: shrink_end(end)

Set the end of the window to the smaller of end and self.end()

Parameters

NameTypeDefaultDescription
endTimeInput-the new end time of the window

Returns

TypeDescription
GraphView

shrink_start

Signature: shrink_start(start)

Set the start of the window to the larger of start and self.start()

Parameters

NameTypeDefaultDescription
startTimeInput-the new start time of the window

Returns

TypeDescription
GraphView

shrink_window

Signature: shrink_window(start, end)

Shrink both the start and end of the window (same as calling shrink_start followed by shrink_end but more efficient)

Parameters

NameTypeDefaultDescription
startTimeInput-the new start time for the window
endTimeInput-the new end time for the window

Returns

TypeDescription
GraphView

snapshot_at

Signature: snapshot_at(time)

Create a view of the GraphView including all events that have not been explicitly deleted at time.

This is equivalent to before(time + 1) for Graph and at(time) for PersistentGraph

Parameters

NameTypeDefaultDescription
timeTimeInput-The time of the window.

Returns

TypeDescription
GraphView

snapshot_latest

Create a view of the GraphView including all events that have not been explicitly deleted at the latest time.

This is equivalent to a no-op for Graph and latest() for PersistentGraph

Returns

TypeDescription
GraphView

subgraph

Signature: subgraph(nodes)

Returns a subgraph given a set of nodes

Parameters

NameTypeDefaultDescription
nodeslist[NodeInput]-set of nodes

Returns

TypeDescription
GraphViewReturns the subgraph

subgraph_node_types

Signature: subgraph_node_types(node_types)

Returns a subgraph filtered by node types given a set of node types

Parameters

NameTypeDefaultDescription
node_typeslist[str]-set of node types

Returns

TypeDescription
GraphViewReturns the subgraph

to_networkx

Signature: to_networkx(explode_edges=False, include_node_properties=True, include_edge_properties=True, include_update_history=True, include_property_history=True)

Returns a graph with NetworkX.

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

NameTypeDefaultDescription
explode_edgesbool, optionalFalseA boolean that is set to True if you want to explode the edges in the graph. Defaults to False.
include_node_propertiesbool, optionalTrueA boolean that is set to True if you want to include the node properties in the graph. Defaults to True.
include_edge_propertiesbool, optionalTrueA boolean that is set to True if you want to include the edge properties in the graph. Defaults to True.
include_update_historybool, optionalTrueA boolean that is set to True if you want to include the update histories in the graph. Defaults to True.
include_property_historybool, optionalTrueA boolean that is set to True if you want to include the histories in the graph. Defaults to True.

Returns

TypeDescription
nx.MultiDiGraphA Networkx MultiDiGraph.

to_pyvis

Signature: to_pyvis(explode_edges=False, edge_color='#000000', shape='dot', node_image=None, edge_weight=None, edge_label=None, colour_nodes_by_type=False, directed=True, notebook=False, kwargs=\{\})

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

Parameters

NameTypeDefaultDescription
explode_edgesbool, optionalFalseA boolean that is set to True if you want to explode the edges in the graph. Defaults to False.
edge_colorstr, optional'#000000'A string defining the colour of the edges in the graph. Defaults to "#000000".
shapestr, optional'dot'A string defining what the node looks like. Defaults to "dot". 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.
node_imagestr, optionalNoneAn optional node property used as the url of a custom node image. Use together with shape="image".
edge_weightstr, optionalNoneAn optional string defining the name of the property where edge weight is set on your Raphtory graph. If provided, the default weight for edges that are missing the property is 1.0.
edge_labelstr, optionalNoneAn optional string defining the name of the property where edge label is set on your Raphtory graph. By default, the edge layer is used as the label.
colour_nodes_by_typebool, optionalFalseIf True, nodes with different types have different colours. Defaults to False.
directedbool, optionalTrueVisualise the graph as directed. Defaults to True.
notebookbool, optionalFalseA boolean that is set to True if using jupyter notebook. Defaults to False. kwargs: Additional keyword arguments that are passed to the pyvis Network class.
kwargsAny\{\}

Returns

TypeDescription
pyvis.network.NetworkA pyvis network

valid

Return a view of the graph that only includes valid edges

Returns

TypeDescription
GraphViewThe filtered graph

valid_layers

Signature: valid_layers(names)

Return a view of GraphView containing all layers names Any layers that do not exist are ignored

Parameters

NameTypeDefaultDescription
nameslist[str]-list of layer names for the new view

Returns

TypeDescription
GraphViewThe layered view

vectorise

Signature: vectorise(embedding, nodes=True, edges=True, cache=None, verbose=False)

Create a VectorisedGraph from the current graph.

Parameters

NameTypeDefaultDescription
embeddingCallable-Specify the embedding function used to vectorise documents into embeddings.
nodesbool | str, optionalTrueEnable for nodes to be embedded, disable for nodes to not be embedded or specify a custom document property to use if a string is provided. Defaults to True.
edgesbool | str, optionalTrueEnable for edges to be embedded, disable for edges to not be embedded or specify a custom document property to use if a string is provided. Defaults to True.
cachestr, optionalNonePath used to store the cache of embeddings.
verbosebool, optionalFalseEnable to print logs reporting progress. Defaults to False.

Returns

TypeDescription
VectorisedGraphA VectorisedGraph with all the documents and their embeddings, with an initial empty selection.

window

Signature: window(start, end)

Create a view of the GraphView including all events between start (inclusive) and end (exclusive)

Parameters

NameTypeDefaultDescription
startTimeInput-The start time of the window.
endTimeInput-The end time of the window.

Returns

TypeDescription
GraphView

Property Details

earliest_time

Time entry of the earliest activity in the graph

Returns

TypeDescription
OptionalEventTimethe time entry of the earliest activity in the graph

edges

Gets all edges in the graph

Returns

TypeDescription
Edgesthe edges in the graph

end

Gets the latest time that this GraphView is valid.

Returns

TypeDescription
OptionalEventTimeThe latest time that this GraphView is valid or None if the GraphView is valid for all times.

latest_time

Time entry of the latest activity in the graph

Returns

TypeDescription
OptionalEventTimethe time entry of the latest activity in the graph

metadata

Get all graph metadata

Returns

TypeDescription
Metadata

nodes

Gets the nodes in the graph

Returns

TypeDescription
Nodesthe nodes in the graph

properties

Get all graph properties

Returns

TypeDescription
PropertiesProperties paired with their names

start

Gets the start time for rolling and expanding windows for this GraphView

Returns

TypeDescription
OptionalEventTimeThe earliest time that this GraphView is valid or None if the GraphView is valid for all times.

unique_layers

Return all the layer ids in the graph

Returns

TypeDescription
list[str]the names of all layers in the graph

window_size

Get the window size (difference between start and end) for this GraphView.

Returns

TypeDescription
int, optional