Edge metrics and functions
Edges can be accessed by storing the object returned from a call to add_edge(), by directly asking for a specific edge via edge(), or by iterating over all edges with in_edges, out_edges, or edges.
Edge structure and update history
By default an edge object in Raphtory will contain all updates over all layers between the given source and destination nodes. As an example, we can look at the two edges between FELIPE and MAKO (one for each direction).
In the code below we create the two edge objects by requesting them from the graph and then print out the layers each is involved in with layer_names. We can see that there are multiple behaviors in each direction represented within the edges.
Following this we access the history to get the earliest_time and latest_time. This update history consists all interactions across all layers.
Edge state functions
Edges have several functions for checking their state:
is_active(): whether the edge is currently active (has updates in the current view)is_valid(): whether the edge exists and is valid in the current viewis_deleted(): whether the edge has been deleted (at the time of the end of the view)is_self_loop(): whether the edge connects a node to itself
In an Event Graph, any edge that is present will be active, valid, and not deleted — unless you apply a view that removes all its history. These functions become more interesting with Persistent Graphs where edges can be explicitly deleted, which we discuss in the Time Semantics section.
Exploded edges
Raphtory offers you three different ways to split an edge by layer, depending on your use case:
layers(): takes a list of layer names and returns a newEdge Viewwhich contains updates for only the specified layers. This is discussed in more detail in the Layer views chapterexplode_layers(): returns an iterable ofEdge Views, each containing the updates for one layerexplode(): returns anExploded Edgecontaining only the information from one call toadd_edge(), in this case an edge object for each update.
In the code below you can see an example of each of these functions. We first call explode_layers(), to see which layer each edge object represents and output its update history. Next we fully explode() the edge and see each update as an individual object. Thirdly we use the layers() function to look at only the Touching and Carrying layers and chain this with a call to explode() to see the separate updates.
Within the examples and in the API documentation you will see singular and plural versions what appear to be the same function. For example layer_names and layer_name.
Singular functions such as .layer_name or .time can be called on exploded edges and plural functions such as .layer_names and .history can be called on standard edges.