GraphView
Graph view is a read-only version of a graph at a certain point in time.
Methods
| Method | Description |
|---|---|
after | Create a view of the GraphView including all events after start (exclusive). |
at | Create a view of the GraphView including all events at time. |
before | Create a view of the GraphView including all events before end (exclusive). |
cache_view | Applies the filters to the graph and retains the node ids and the edge ids |
count_edges | Number of edges in the graph |
count_nodes | Number of nodes in the graph |
count_temporal_edges | Number of edges in the graph |
default_layer | Return a view of GraphView containing only the default edge layer |
edge | Gets the edge with the specified source and destination nodes |
exclude_layer | Return a view of GraphView containing all layers except the excluded name |
exclude_layers | Return a view of GraphView containing all layers except the excluded names |
exclude_nodes | Returns a subgraph given a set of nodes that are excluded from the subgraph |
exclude_valid_layer | Return a view of GraphView containing all layers except the excluded name |
exclude_valid_layers | Return a view of GraphView containing all layers except the excluded names |
expanding | Creates a WindowSet with the given step size using an expanding window. |
filter | Return a filtered view that only includes nodes and edges that satisfy the filter |
find_edges | Get the edges that match the properties name and value |
find_nodes | Get the nodes that match the properties name and value |
get_index_spec | Get index spec |
has_edge | Returns true if the graph contains the specified edge |
has_layer | Check if GraphView has the layer "name" |
has_node | Returns true if the graph contains the specified node |
latest | Create a view of the GraphView including all events at the latest time. |
layer | Return a view of GraphView containing the layer "name" |
layers | Return a view of GraphView containing all layers names |
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 |
node | Gets the node with the specified id |
rolling | Creates a WindowSet with the given window size and optional step using a rolling window. |
search_edges | Searches for edges which match the given filter expression. This uses Tantivy's exact search. |
search_nodes | Searches for nodes which match the given filter expression. This uses Tantivy's exact search. |
shrink_end | Set the end of the window to the smaller of end and self.end() |
shrink_start | Set the start of the window to the larger of start and self.start() |
shrink_window | Shrink both the start and end of the window (same as calling shrink_start followed by shrink_end but more efficient) |
snapshot_at | Create a view of the GraphView including all events that have not been explicitly deleted at time. |
snapshot_latest | Create a view of the GraphView including all events that have not been explicitly deleted at the latest time. |
subgraph | Returns a subgraph given a set of nodes |
subgraph_node_types | Returns a subgraph filtered by node types given a set of node types |
to_networkx | Returns a graph with NetworkX. |
to_pyvis | Draw a graph with PyVis. |
valid | Return a view of the graph that only includes valid edges |
valid_layers | Return a view of GraphView containing all layers names |
vectorise | Create a VectorisedGraph from the current graph. |
window | Create a view of the GraphView including all events between start (inclusive) and end (exclusive) |
Properties
| Property | Description |
|---|---|
earliest_time | Time entry of the earliest activity in the graph |
edges | Gets all edges in the graph |
end | Gets the latest time that this GraphView is valid. |
latest_time | Time entry of the latest activity in the graph |
metadata | Get all graph metadata |
nodes | Gets the nodes in the graph |
properties | Get all graph properties |
start | Gets the start time for rolling and expanding windows for this GraphView |
unique_layers | Return all the layer ids in the graph |
window_size | Get 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
| Name | Type | Default | Description |
|---|---|---|---|
start | TimeInput | - | The start time of the window. |
Returns
| Type | Description |
|---|---|
| GraphView |
at
Signature: at(time)
Create a view of the GraphView including all events at time.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
time | TimeInput | - | The time of the window. |
Returns
| Type | Description |
|---|---|
| GraphView |
before
Signature: before(end)
Create a view of the GraphView including all events before end (exclusive).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
end | TimeInput | - | The end time of the window. |
Returns
| Type | Description |
|---|---|
| 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
| Type | Description |
|---|---|
| GraphView | Returns the masked graph |
count_edges
Number of edges in the graph
Returns
| Type | Description |
|---|---|
| int | the number of edges in the graph |
count_nodes
Number of nodes in the graph
Returns
| Type | Description |
|---|---|
| int | the number of nodes in the graph |
count_temporal_edges
Number of edges in the graph
Returns
| Type | Description |
|---|---|
| int | the number of temporal edges in the graph |
default_layer
Return a view of GraphView containing only the default edge layer
Returns
| Type | Description |
|---|---|
| GraphView | The layered view |
edge
Signature: edge(src, dst)
Gets the edge with the specified source and destination nodes
Parameters
Returns
| Type | Description |
|---|---|
| Edge, optional | the 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
| Name | Type | Default | Description |
|---|---|---|---|
name | str | - | layer name that is excluded for the new view |
Returns
| Type | Description |
|---|---|
| GraphView | The 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
| Name | Type | Default | Description |
|---|---|---|---|
names | list[str] | - | list of layer names that are excluded for the new view |
Returns
| Type | Description |
|---|---|
| GraphView | The layered view |
exclude_nodes
Signature: exclude_nodes(nodes)
Returns a subgraph given a set of nodes that are excluded from the subgraph
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
nodes | list[NodeInput] | - | set of nodes |
Returns
| Type | Description |
|---|---|
| GraphView | Returns the subgraph |
exclude_valid_layer
Signature: exclude_valid_layer(name)
Return a view of GraphView containing all layers except the excluded name
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | - | layer name that is excluded for the new view |
Returns
| Type | Description |
|---|---|
| GraphView | The layered view |
exclude_valid_layers
Signature: exclude_valid_layers(names)
Return a view of GraphView containing all layers except the excluded names
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
names | list[str] | - | list of layer names that are excluded for the new view |
Returns
| Type | Description |
|---|---|
| GraphView | The 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
| Name | Type | Default | Description |
|---|---|---|---|
step | int | str | - | The step size of the window. |
alignment_unit | str | None, optional | None | If 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
| Type | Description |
|---|---|
| WindowSet | A WindowSet object. |
filter
Signature: filter(filter)
Return a filtered view that only includes nodes and edges that satisfy the filter
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
filter | filter.FilterExpr | - | The filter to apply to the nodes and edges. |
Returns
| Type | Description |
|---|---|
| GraphView | The filtered view |
find_edges
Signature: find_edges(properties_dict)
Get the edges that match the properties name and value
Parameters
Returns
| Type | Description |
|---|---|
| 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
Returns
| Type | Description |
|---|---|
| list[Node] | the nodes that match the properties name and value |
get_index_spec
Get index spec
Returns
| Type | Description |
|---|---|
| IndexSpec |
has_edge
Signature: has_edge(src, dst)
Returns true if the graph contains the specified edge
Parameters
Returns
| Type | Description |
|---|---|
| bool | true if the graph contains the specified edge, false otherwise |
has_layer
Signature: has_layer(name)
Check if GraphView has the layer "name"
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | - | the name of the layer to check |
Returns
| Type | Description |
|---|---|
| bool |
has_node
Signature: has_node(id)
Returns true if the graph contains the specified node
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | NodeInput | - | the node id |
Returns
| Type | Description |
|---|---|
| bool | true if the graph contains the specified node, false otherwise |
latest
Create a view of the GraphView including all events at the latest time.
Returns
| Type | Description |
|---|---|
| GraphView |
layer
Signature: layer(name)
Return a view of GraphView containing the layer "name"
Errors if the layer does not exist
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | - | then name of the layer. |
Returns
| Type | Description |
|---|---|
| GraphView | The 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
| Name | Type | Default | Description |
|---|---|---|---|
names | list[str] | - | list of layer names for the new view |
Returns
| Type | Description |
|---|---|
| GraphView | The 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
| Type | Description |
|---|---|
| GraphView | Returns a graph clone |
node
Signature: node(id)
Gets the node with the specified id
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | NodeInput | - | the node id |
Returns
| Type | Description |
|---|---|
| Node, optional | the 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
| Name | Type | Default | Description |
|---|---|---|---|
window | int | str | - | The size of the window. |
step | int | str | None, optional | None | The step size of the window. step defaults to window. |
alignment_unit | str | None, optional | None | If 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
| Type | Description |
|---|---|
| WindowSet | A 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
| Name | Type | Default | Description |
|---|---|---|---|
limit | int, optional | 25 | The maximum number of results to return. Defaults to 25. |
offset | int, optional | 0 | The number of results to skip. This is useful for pagination. Defaults to 0. |
filter | Any | - |
Returns
| Type | Description |
|---|---|
| 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
| Name | Type | Default | Description |
|---|---|---|---|
limit | int, optional | 25 | The maximum number of results to return. Defaults to 25. |
offset | int, optional | 0 | The number of results to skip. This is useful for pagination. Defaults to 0. |
filter | Any | - |
Returns
| Type | Description |
|---|---|
| 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
| Name | Type | Default | Description |
|---|---|---|---|
end | TimeInput | - | the new end time of the window |
Returns
| Type | Description |
|---|---|
| GraphView |
shrink_start
Signature: shrink_start(start)
Set the start of the window to the larger of start and self.start()
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
start | TimeInput | - | the new start time of the window |
Returns
| Type | Description |
|---|---|
| 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
| Name | Type | Default | Description |
|---|---|---|---|
start | TimeInput | - | the new start time for the window |
end | TimeInput | - | the new end time for the window |
Returns
| Type | Description |
|---|---|
| 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
| Name | Type | Default | Description |
|---|---|---|---|
time | TimeInput | - | The time of the window. |
Returns
| Type | Description |
|---|---|
| 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
| Type | Description |
|---|---|
| GraphView |
subgraph
Signature: subgraph(nodes)
Returns a subgraph given a set of nodes
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
nodes | list[NodeInput] | - | set of nodes |
Returns
| Type | Description |
|---|---|
| GraphView | Returns 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
| Name | Type | Default | Description |
|---|---|---|---|
node_types | list[str] | - | set of node types |
Returns
| Type | Description |
|---|---|
| GraphView | Returns 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
| Name | Type | Default | Description |
|---|---|---|---|
explode_edges | bool, optional | False | A boolean that is set to True if you want to explode the edges in the graph. Defaults to False. |
include_node_properties | bool, optional | True | A boolean that is set to True if you want to include the node properties in the graph. Defaults to True. |
include_edge_properties | bool, optional | True | A boolean that is set to True if you want to include the edge properties in the graph. Defaults to True. |
include_update_history | bool, optional | True | A boolean that is set to True if you want to include the update histories in the graph. Defaults to True. |
include_property_history | bool, optional | True | A boolean that is set to True if you want to include the histories in the graph. Defaults to True. |
Returns
| Type | Description |
|---|---|
nx.MultiDiGraph | A 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
| Name | Type | Default | Description |
|---|---|---|---|
explode_edges | bool, optional | False | A boolean that is set to True if you want to explode the edges in the graph. Defaults to False. |
edge_color | str, optional | '#000000' | A string defining the colour of the edges in the graph. Defaults to "#000000". |
shape | str, 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_image | str, optional | None | An optional node property used as the url of a custom node image. Use together with shape="image". |
edge_weight | str, optional | None | An 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_label | str, optional | None | An 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_type | bool, optional | False | If True, nodes with different types have different colours. Defaults to False. |
directed | bool, optional | True | Visualise the graph as directed. Defaults to True. |
notebook | bool, optional | False | A 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. |
kwargs | Any | \{\} |
Returns
| Type | Description |
|---|---|
pyvis.network.Network | A pyvis network |
valid
Return a view of the graph that only includes valid edges
Returns
| Type | Description |
|---|---|
| GraphView | The 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
| Name | Type | Default | Description |
|---|---|---|---|
names | list[str] | - | list of layer names for the new view |
Returns
| Type | Description |
|---|---|
| GraphView | The layered view |
vectorise
Signature: vectorise(embedding, nodes=True, edges=True, cache=None, verbose=False)
Create a VectorisedGraph from the current graph.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
embedding | Callable | - | Specify the embedding function used to vectorise documents into embeddings. |
nodes | bool | str, optional | True | Enable 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. |
edges | bool | str, optional | True | Enable 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. |
cache | str, optional | None | Path used to store the cache of embeddings. |
verbose | bool, optional | False | Enable to print logs reporting progress. Defaults to False. |
Returns
| Type | Description |
|---|---|
| VectorisedGraph | A 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
| Name | Type | Default | Description |
|---|---|---|---|
start | TimeInput | - | The start time of the window. |
end | TimeInput | - | The end time of the window. |
Returns
| Type | Description |
|---|---|
| GraphView |
Property Details
earliest_time
Time entry of the earliest activity in the graph
Returns
| Type | Description |
|---|---|
| OptionalEventTime | the time entry of the earliest activity in the graph |
edges
Gets all edges in the graph
Returns
| Type | Description |
|---|---|
| Edges | the edges in the graph |
end
Gets the latest time that this GraphView is valid.
Returns
| Type | Description |
|---|---|
| OptionalEventTime | The 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
| Type | Description |
|---|---|
| OptionalEventTime | the time entry of the latest activity in the graph |
metadata
Get all graph metadata
Returns
| Type | Description |
|---|---|
| Metadata |
nodes
Gets the nodes in the graph
Returns
| Type | Description |
|---|---|
| Nodes | the nodes in the graph |
properties
Get all graph properties
Returns
| Type | Description |
|---|---|
| Properties | Properties paired with their names |
start
Gets the start time for rolling and expanding windows for this GraphView
Returns
| Type | Description |
|---|---|
| OptionalEventTime | The 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
| Type | Description |
|---|---|
| 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
| Type | Description |
|---|---|
| int, optional |