Skip to content

Edge #

Bases: object

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

deletions property #

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

Returns:

Type Description
History

A history object containing time entries about the edge's deletions

dst property #

Returns the destination node of the edge.

Returns:

Type Description
Node

earliest_time property #

Gets the earliest time of an edge.

Returns:

Type Description
OptionalEventTime

The earliest time of an edge

end property #

Gets the latest time that this Edge is valid.

Returns:

Type Description
OptionalEventTime

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

history property #

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

Returns:

Type Description
History

A history object containing temporal entries about the edge

id property #

The id of the edge.

Returns:

Type Description
GID

latest_time property #

Gets the latest time of an edge.

Returns:

Type Description
OptionalEventTime

The latest time of an edge

layer_name property #

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

Returns:

Type Description
str

The name of the layer

layer_names property #

Gets the names of the layers this edge belongs to.

Returns:

Type Description
List[str]

The name of the layer

metadata property #

Gets the metadata of an edge

Returns:

Type Description
Metadata

nbr property #

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

Returns:

Type Description
Nodes

properties property #

Returns a view of the properties of the edge.

Returns:

Type Description
Properties

Properties on the Edge.

src property #

Returns the source node of the edge.

Returns:

Type Description
Nodes

start property #

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

Returns:

Type Description
OptionalEventTime

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

time property #

Gets the time of an exploded edge.

Returns:

Type Description
int

The time of an exploded edge

window_size property #

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

Returns:

Type Description
Optional[int]

__eq__(value) #

Return self==value.

__ge__(value) #

Return self>=value.

__getitem__(key) #

Return self[key].

__gt__(value) #

Return self>value.

__hash__() #

Return hash(self).

__le__(value) #

Return self<=value.

__lt__(value) #

Return self<value.

__ne__(value) #

Return self!=value.

__repr__() #

Return repr(self).

after(start) #

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

Parameters:

Name Type Description Default
start TimeInput

The start time of the window.

required

Returns:

Type Description
Edge

at(time) #

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

Parameters:

Name Type Description Default
time TimeInput

The time of the window.

required

Returns:

Type Description
Edge

before(end) #

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

Parameters:

Name Type Description Default
end TimeInput

The end time of the window.

required

Returns:

Type Description
Edge

default_layer() #

Return a view of Edge containing only the default edge layer Returns: Edge: The layered view

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:

Name Type Description Default
name str

layer name that is excluded for the new view

required

Returns:

Type Description
Edge

The layered view

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:

Name Type Description Default
names list[str]

list of layer names that are excluded for the new view

required

Returns:

Type Description
Edge

The layered view

exclude_valid_layer(name) #

Return a view of Edge containing all layers except the excluded name Arguments: name (str): layer name that is excluded for the new view

Returns:

Type Description
Edge

The layered view

exclude_valid_layers(names) #

Return a view of Edge containing all layers except the excluded names Arguments: names (list[str]): list of layer names that are excluded for the new view

Returns:

Type Description
Edge

The layered view

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 Description Default
step int | str

The step size of the window.

required
alignment_unit str | 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.

None

Returns:

Type Description
WindowSet

A WindowSet object.

explode() #

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

Returns:

Type Description
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:

Type Description
Edges

has_layer(name) #

Check if Edge has the layer "name"

Parameters:

Name Type Description Default
name str

the name of the layer to check

required

Returns:

Type Description
bool

is_active() #

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

is_deleted() #

Check if the edge is currently deleted Returns: bool:

is_self_loop() #

Check if the edge is on the same node Returns: bool:

is_valid() #

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

latest() #

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

Returns:

Type Description
Edge

layer(name) #

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

Parameters:

Name Type Description Default
name str

then name of the layer.

required

Returns:

Type Description
Edge

The layered view

layers(names) #

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

Parameters:

Name Type Description Default
names list[str]

list of layer names for the new view

required

Returns:

Type Description
Edge

The layered view

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 Description Default
window int | str

The size of the window.

required
step int | str | None

The step size of the window. step defaults to window.

None
alignment_unit str | 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.

None

Returns:

Type Description
WindowSet

A WindowSet object.

shrink_end(end) #

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

Parameters:

Name Type Description Default
end TimeInput

the new end time of the window

required

Returns: Edge:

shrink_start(start) #

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

Parameters:

Name Type Description Default
start TimeInput

the new start time of the window

required

Returns:

Type Description
Edge

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 Description Default
start TimeInput

the new start time for the window

required
end TimeInput

the new end time for the window

required

Returns:

Type Description
Edge

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:

Name Type Description Default
time TimeInput

The time of the window.

required

Returns:

Type Description
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:

Type Description
Edge

valid_layers(names) #

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

Parameters:

Name Type Description Default
names list[str]

list of layer names for the new view

required

Returns:

Type Description
Edge

The layered view

window(start, end) #

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

Parameters:

Name Type Description Default
start TimeInput

The start time of the window.

required
end TimeInput

The end time of the window.

required

Returns:

Type Description
Edge