Edges

A list of edges that can be iterated over.

Methods

MethodDescription
afterCreate a view of the Edges including all events after start (exclusive).
atCreate a view of the Edges including all events at time.
beforeCreate a view of the Edges including all events before end (exclusive).
collectCollect all edges into a list
countReturns the number of edges.
default_layerReturn a view of Edges containing only the default edge layer
exclude_layerReturn a view of Edges containing all layers except the excluded name
exclude_layersReturn a view of Edges containing all layers except the excluded names
exclude_valid_layerReturn a view of Edges containing all layers except the excluded name
exclude_valid_layersReturn a view of Edges containing all layers except the excluded names
expandingCreates a WindowSet with the given step size using an expanding window.
explodeExplodes returns an edge object for each update within the original edge.
explode_layersExplode layers returns an edge object for each layer within the original edge. These new edge object contains only updates from respective layers.
has_layerCheck if Edges has the layer "name"
is_activeCheck if the edges are active (there is at least one update during this time).
is_deletedCheck if the edges are deleted.
is_self_loopCheck if the edges are on the same node.
is_validCheck if the edges are valid (i.e. not deleted).
latestCreate a view of the Edges including all events at the latest time.
layerReturn a view of Edges containing the layer "name"
layersReturn a view of Edges containing all layers names
rollingCreates a WindowSet with the given window size and optional step using a rolling window.
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 Edges including all events that have not been explicitly deleted at time.
snapshot_latestCreate a view of the Edges including all events that have not been explicitly deleted at the latest time.
to_dfConverts the graph's edges into a Pandas DataFrame.
valid_layersReturn a view of Edges containing all layers names
windowCreate a view of the Edges including all events between start (inclusive) and end (exclusive)

Properties

PropertyDescription
deletionsReturns a history object for each edge containing their deletion times.
dstReturns the destination node of the edge.
earliest_timeReturns the earliest time of the edges.
endGets the latest time that this Edges is valid.
historyReturns a history object for each edge containing time entries for when the edge is added or change to the edge is made.
idReturns all ids of the edges.
latest_timeReturns the latest times of the edges.
layer_nameGet the layer name that all edges belong to - assuming they only belong to one layer
layer_namesGet the layer names that all edges belong to - assuming they only belong to one layer.
metadataReturns all the metadata of the edges
nbrReturns the node at the other end of the edge (same as dst() for out-edges and src() for in-edges)
propertiesReturns all properties of the edges
srcReturns the source node of the edge.
startGets the start time for rolling and expanding windows for this Edges
timeReturns the times of exploded edges
window_sizeGet the window size (difference between start and end) for this Edges.

Method Details

after

Signature: after(start)

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

Parameters

NameTypeDefaultDescription
startTimeInput-The start time of the window.

Returns

TypeDescription
Edges

at

Signature: at(time)

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

Parameters

NameTypeDefaultDescription
timeTimeInput-The time of the window.

Returns

TypeDescription
Edges

before

Signature: before(end)

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

Parameters

NameTypeDefaultDescription
endTimeInput-The end time of the window.

Returns

TypeDescription
Edges

collect

Collect all edges into a list

Returns

TypeDescription
list[Edge]the list of edges

count

Returns the number of edges.

Returns

TypeDescription
int

default_layer

Return a view of Edges containing only the default edge layer

Returns

TypeDescription
EdgesThe layered view

exclude_layer

Signature: exclude_layer(name)

Return a view of Edges 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
EdgesThe layered view

exclude_layers

Signature: exclude_layers(names)

Return a view of Edges 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
EdgesThe layered view

exclude_valid_layer

Signature: exclude_valid_layer(name)

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

Parameters

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

Returns

TypeDescription
EdgesThe layered view

exclude_valid_layers

Signature: exclude_valid_layers(names)

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

Parameters

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

Returns

TypeDescription
EdgesThe 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.

explode

Explodes returns an edge object for each update within the original edge.

Returns

TypeDescription
Edges

explode_layers

Explode layers returns an edge object for each layer within the original edge. These new edge object contains only updates from respective layers.

Returns

TypeDescription
Edges

has_layer

Signature: has_layer(name)

Check if Edges has the layer "name"

Parameters

NameTypeDefaultDescription
namestr-the name of the layer to check

Returns

TypeDescription
bool

is_active

Check if the edges are active (there is at least one update during this time).

Returns

TypeDescription
BoolIterable

is_deleted

Check if the edges are deleted.

Returns

TypeDescription
BoolIterable

is_self_loop

Check if the edges are on the same node.

Returns

TypeDescription
BoolIterable

is_valid

Check if the edges are valid (i.e. not deleted).

Returns

TypeDescription
BoolIterable

latest

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

Returns

TypeDescription
Edges

layer

Signature: layer(name)

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

Parameters

NameTypeDefaultDescription
namestr-then name of the layer.

Returns

TypeDescription
EdgesThe layered view

layers

Signature: layers(names)

Return a view of Edges 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
EdgesThe layered view

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.

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
Edges

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
Edges

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
Edges

snapshot_at

Signature: snapshot_at(time)

Create a view of the Edges 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
Edges

snapshot_latest

Create a view of the Edges 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
Edges

to_df

Signature: to_df(include_property_history=True, convert_datetime=False, explode=False)

Converts the graph's edges into a Pandas DataFrame.

This method will create a DataFrame with the following columns:

  • "src": The source node of the edge.
  • "dst": The destination node of the edge.
  • "layer": The layer of the edge.
  • "properties": The properties of the edge.
  • "update_history": The update history of the edge. This column will be included if include_update_history is set to true.

Parameters

NameTypeDefaultDescription
include_property_historybool, optionalTrueA boolean, if set to True, the history of each property is included, if False, only the latest value is shown. Ignored if exploded. Defaults to True.
convert_datetimebool, optionalFalseA boolean, if set to True will convert the timestamp to python datetimes. Defaults to False.
explodebool, optionalFalseA boolean, if set to True, will explode each edge update into its own row. Defaults to False.

Returns

TypeDescription
DataFrameIf successful, this PyObject will be a Pandas DataFrame.

valid_layers

Signature: valid_layers(names)

Return a view of Edges 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
EdgesThe layered view

window

Signature: window(start, end)

Create a view of the Edges 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
Edges

Property Details

deletions

Returns a history object for each edge containing their deletion times.

Returns

TypeDescription
HistoryIterableAn iterable of history objects, one for each edge.

dst

Returns the destination node of the edge.

Returns

TypeDescription
Node

earliest_time

Returns the earliest time of the edges.

Returns

TypeDescription
OptionEventTimeIterableIterable of EventTimes.

end

Gets the latest time that this Edges is valid.

Returns

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

history

Returns a history object for each edge containing time entries for when the edge is added or change to the edge is made.

Returns

TypeDescription
HistoryIterableAn iterable of history objects, one for each edge.

id

Returns all ids of the edges.

Returns

TypeDescription
GIDGIDIterable

latest_time

Returns the latest times of the edges.

Returns

TypeDescription
OptionEventTimeIterableIterable of EventTimes.

layer_name

Get the layer name that all edges belong to - assuming they only belong to one layer

Returns

TypeDescription
ArcStringIterable

layer_names

Get the layer names that all edges belong to - assuming they only belong to one layer.

Returns

TypeDescription
ArcStringVecIterable

metadata

Returns all the metadata of the edges

Returns

TypeDescription
MetadataView

nbr

Returns the node at the other end of the edge (same as dst() for out-edges and src() for in-edges)

Returns

TypeDescription
Nodes

properties

Returns all properties of the edges

Returns

TypeDescription
PropertiesView

src

Returns the source node of the edge.

Returns

TypeDescription
Nodes

start

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

Returns

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

time

Returns the times of exploded edges

Returns

TypeDescription
EventTimeIterableIterable of EventTimes.

window_size

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

Returns

TypeDescription
int, optional