Edge

PyEdge is a Python class that represents an edge in the graph. An edge is a directed connection between two nodes.

Methods

MethodDescription
afterCreate a view of the Edge including all events after start (exclusive).
atCreate a view of the Edge including all events at time.
beforeCreate a view of the Edge including all events before end (exclusive).
default_layerReturn a view of Edge containing only the default edge layer
exclude_layerReturn a view of Edge containing all layers except the excluded name
exclude_layersReturn a view of Edge containing all layers except the excluded names
exclude_valid_layerReturn a view of Edge containing all layers except the excluded name
exclude_valid_layersReturn a view of Edge 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 Edge has the layer "name"
is_activeCheck if the edge is currently active (has at least one update within this period).
is_deletedCheck if the edge is currently deleted
is_self_loopCheck if the edge is on the same node
is_validCheck if the edge is currently valid (i.e., not deleted)
latestCreate a view of the Edge including all events at the latest time.
layerReturn a view of Edge containing the layer "name"
layersReturn a view of Edge 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 Edge including all events that have not been explicitly deleted at time.
snapshot_latestCreate a view of the Edge including all events that have not been explicitly deleted at the latest time.
valid_layersReturn a view of Edge containing all layers names
windowCreate a view of the Edge including all events between start (inclusive) and end (exclusive)

Properties

PropertyDescription
deletionsReturns a history object with EventTime entries for an edge's deletion times.
dstReturns the destination node of the edge.
earliest_timeGets the earliest time of an edge.
endGets the latest time that this Edge is valid.
historyReturns a history object with EventTime entries for when an edge is added or change to an edge is made.
idThe id of the edge.
latest_timeGets the latest time of an edge.
layer_nameGets the name of the layer this edge belongs to - assuming it only belongs to one layer.
layer_namesGets the names of the layers this edge belongs to.
metadataGets the metadata of an edge
nbrReturns the node at the other end of the edge (same as dst() for out-edges and src() for in-edges)
propertiesReturns a view of the properties of the edge.
srcReturns the source node of the edge.
startGets the start time for rolling and expanding windows for this Edge
timeGets the time of an exploded edge.
window_sizeGet the window size (difference between start and end) for this Edge.

Method Details

after

Signature: after(start)

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

Parameters

NameTypeDefaultDescription
startTimeInput-The start time of the window.

Returns

TypeDescription
Edge

at

Signature: at(time)

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

Parameters

NameTypeDefaultDescription
timeTimeInput-The time of the window.

Returns

TypeDescription
Edge

before

Signature: before(end)

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

Parameters

NameTypeDefaultDescription
endTimeInput-The end time of the window.

Returns

TypeDescription
Edge

default_layer

Return a view of Edge containing only the default edge layer

Returns

TypeDescription
EdgeThe layered view

exclude_layer

Signature: exclude_layer(name)

Return a view of Edge 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
EdgeThe layered view

exclude_layers

Signature: exclude_layers(names)

Return a view of Edge 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
EdgeThe layered view

exclude_valid_layer

Signature: exclude_valid_layer(name)

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

Parameters

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

Returns

TypeDescription
EdgeThe layered view

exclude_valid_layers

Signature: exclude_valid_layers(names)

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

Parameters

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

Returns

TypeDescription
EdgeThe 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 Edge has the layer "name"

Parameters

NameTypeDefaultDescription
namestr-the name of the layer to check

Returns

TypeDescription
bool

is_active

Check if the edge is currently active (has at least one update within this period).

Returns

TypeDescription
bool

is_deleted

Check if the edge is currently deleted

Returns

TypeDescription
bool

is_self_loop

Check if the edge is on the same node

Returns

TypeDescription
bool

is_valid

Check if the edge is currently valid (i.e., not deleted)

Returns

TypeDescription
bool

latest

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

Returns

TypeDescription
Edge

layer

Signature: layer(name)

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

Parameters

NameTypeDefaultDescription
namestr-then name of the layer.

Returns

TypeDescription
EdgeThe layered view

layers

Signature: layers(names)

Return a view of Edge 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
EdgeThe 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
Edge

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
Edge

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
Edge

snapshot_at

Signature: snapshot_at(time)

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

snapshot_latest

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

valid_layers

Signature: valid_layers(names)

Return a view of Edge 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
EdgeThe layered view

window

Signature: window(start, end)

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

Property Details

deletions

Returns a history object with EventTime entries for an edge's deletion times.

Returns

TypeDescription
HistoryA history object containing time entries about the edge's deletions

dst

Returns the destination node of the edge.

Returns

TypeDescription
Node

earliest_time

Gets the earliest time of an edge.

Returns

TypeDescription
OptionalEventTimeThe earliest time of an edge

end

Gets the latest time that this Edge is valid.

Returns

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

history

Returns a history object with EventTime entries for when an edge is added or change to an edge is made.

Returns

TypeDescription
HistoryA history object containing temporal entries about the edge

id

The id of the edge.

Returns

TypeDescription
GID

latest_time

Gets the latest time of an edge.

Returns

TypeDescription
OptionalEventTimeThe latest time of an edge

layer_name

Gets the name of the layer this edge belongs to - assuming it only belongs to one layer.

Returns

TypeDescription
strThe name of the layer

layer_names

Gets the names of the layers this edge belongs to.

Returns

TypeDescription
list[str]The name of the layer

metadata

Gets the metadata of an edge

Returns

TypeDescription
Metadata

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 a view of the properties of the edge.

Returns

TypeDescription
PropertiesProperties on the Edge.

src

Returns the source node of the edge.

Returns

TypeDescription
Nodes

start

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

Returns

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

time

Gets the time of an exploded edge.

Returns

TypeDescription
intThe time of an exploded edge

window_size

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

Returns

TypeDescription
int, optional