Struct net_ensembles::GenericGraph[][src]

pub struct GenericGraph<T, A> { /* fields omitted */ }
Expand description

Generic graph implementation

  • contains multiple measurable quantities

Implementations

Create new graph with size nodes and no edges

create a new graph
  • graph will contain contained.len() vertices, which will contain the corresponding entries of the vector contained
  • graph will not contain any edges upon creation
use net_ensembles::{GenericGraph, graph::NodeContainer};
 
let graph = GenericGraph::<_, NodeContainer::<_>>::from_vec(vec!["first", "second", "third"]);
assert_eq!(graph.at(0), &"first");
assert_eq!(graph.at(1), &"second");
assert_eq!(graph.at(2), &"third");
assert_eq!(graph.vertex_count(), 3);
assert_eq!(graph.edge_count(), 0);
removes all edges from the graph
  • inexpensive O(1), if there are no edges to begin with
  • O(vertices) otherwise
Sort adjecency lists

If you depend on the order of the adjecency lists, you can sort them

Performance
  • internally uses pattern-defeating quicksort as long as that is the standard
  • sorts an adjecency list with length d in worst-case: O(d log(d))
  • is called for each adjecency list, i.e., self.vertex_count() times
get AdjContainer of vertex index
  • panics if index out of bounds
get AdjContainer of vertex index
  • None if index is out of bounds
  • Some(&A) else
  • get iterator over AdjContainer in order of the indices
  • iterator returns AdjContainer<Node>
  • iterate over AdjContainer of neighbors of vertex index

  • iterator returns AdjContainer<Node>

  • sort_adj will affect the order

    If let mut iter = self.contained_iter_neighbors() is called directly after self.sort_adj(), the following will be true (as long as iter does not return None of cause): iter.next().unwrap().id() < iter.next().unwrap.id() < ... Note, that ...id() returns the index of the corresponding vertex

  • panics if index out of bounds

  • get iterator over additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • similar to self.container_iter().map(|container| container.contained())
  • same as contained_iter, but mutable
  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • iterate over additional information of neighbors of vertex index
  • iterator returns (index_neighbor,&T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • See also: GraphIteratorsMut
  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • See also: GraphIteratorsMut
For your calculations etc.
  • read access to your struct T, stored at each vertex, that implements Node trait
Note
  • panics if index out of bounds
For your calculations etc.
  • read access to your struct T, stored at each vertex, that implements Node trait
  • None if index is out of bounds
For your calculations etc.
  • write access to your struct T, stored at each vertex, that implements Node trait
Note
  • panics if index out of bounds

returns number of vertices present in graph

calculates the average degree of the graph

  • (2 * edge_count) / vertex_count

Returns a reference to the element stored in the specified node or None if out of Bounds

Returns a mutable reference to the element stored in the specified node or None if out of Bounds

Returns a reference to the element stored in the specified node

For a save alternative see get_contained

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Returns a mutable reference to the element stored in the specified node

For a save alternative see get_contained_mut

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Adds edge between nodes index1 and index2

ErrorCases:
ErrorReason
GraphErrors::IndexOutOfRangeindex1 or index2 larger than self.vertex_count()
GraphErrors::EdgeExistsrequested edge already exists!
panics
  • if indices out of bounds
  • in debug: If index0 == index1

Removes edge between nodes index1 and index2

ErrorCases:
ErrorReason
GraphErrors::IndexOutOfRangeindex1 or index2 larger than self.vertex_count()
GraphErrors::EdgeDoesNotExistrequested edge does not exists
panics
  • if index out of bounds
  • in debug: If index0 == index1

returns total number of edges in graph

  • returns number of vertices adjacent to vertex index
  • None if index out of bounds
Iterator

Iterate over the degrees of each node (in the order of the indices)

get degree vector
  • returns vector of length self.vertex_count() where each entry corresponds to the degree of the vertex with the respective index
Get a histogram of the degrees
  • You can look at your degree distribution with this
Safety
  • Assumes you have at least one node, panics otherwise
returns Iterator
  • the iterator will iterate over the vertices in depth first search order, beginning with vertex index.
  • iterator returns what is contained at the corresponding vertices, i.e., &T
  • iterator always returns None if index out of bounds
Order

Order is guaranteed to be in DFS order, however if this order is not unambiguous adding edges and especially removing edges will shuffle the order.

Note:

Will only iterate over vertices within the connected component that contains vertex index

returns Iterator
  • the iterator will iterate over the vertices in depth first search order, beginning with vertex index.
  • iterator returns what is contained at the corresponding vertices, i.e., &mut T
  • iterator always returns None if index out of bounds
Order

Order is guaranteed to be in DFS order, however if this order is not unambiguous adding edges and especially removing edges will shuffle the order.

Note:

Will only iterate over vertices within the connected component that contains vertex index

returns Iterator
  • the iterator will iterate over the vertices in depth first search order, beginning with vertex index.
  • Iterator returns tuple (index, node)
  • iterator always returns None if index out of bounds
Order

Order is guaranteed to be in DFS order, however if this order is not unambigouse adding edges and especially removing edges will shuffle the order.

Note:

Will only iterate over vertices within the connected component that contains vertex index

returns Iterator
  • the iterator will iterate over the vertices in breadth first search order, beginning with vertex index.
  • Iterator returns tuple (index, node, depth) where node is what is contained at the corresponding index, i.e., &T
depth
  • starts at 0 (i.e. the first element in the iterator will have depth = 0)
  • depth equals number of edges in the shortest path from the current vertex to the first vertex (i.e. to the vertex with index index)
Order

Order is guaranteed to be in BFS order, however if this order is not unambigouse adding edges and especially removing edges will shuffle the order.

Note:

Will only iterate over vertices within the connected component that contains vertex index

returns Iterator
  • the iterator will iterate over the vertices in breadth first search order, beginning with vertex index.
  • Iterator returns tuple (index, node, depth) where node is what is contained at the corresponding index, i.e., &mut T
depth
  • starts at 0 (i.e. the first element in the iterator will have depth = 0)
  • depth equals number of edges in the shortest path from the current vertex to the first vertex (i.e. to the vertex with index index)
Order

Order is guaranteed to be in BFS order, however if this order is not unambigouse adding edges and especially removing edges will shuffle the order.

Note:

Will only iterate over vertices within the connected component that contains vertex index

  • similar to self.bfs_index_depth, but allows for ignoring of vertices

  • the iterator will iterate over the vertices in breadth first search order, beginning with vertex index.

  • the iterator will ignore all vertices, where filter(vertex, index_of_vertex) returns false

  • returns Noneif index is out of bounds or filter(vertex, index)retruns false

  • Iterator returns tuple (index, vertex, depth)

depth
  • starts at 0 (i.e. the first element in the iterator will have depth = 0)
  • depth equals number of edges in the shortest path from the current vertex to the first vertex (i.e. to the vertex with index index), while ignoring paths that go through filtered out vertices
Order

Order is guaranteed to be in BFS order, however if this order is not unambigouse adding edges and especially removing edges will shuffle the order.

Note:

Will only iterate over vertices within the connected component that contains vertex index

resultcondition
Noneif graph does not contain any vertices
Some(true)else if all vertices are connected by paths of edges
Some(false)otherwise
definition

Calculates the size of the q-core (i.e. number of nodes in the biggest possible set of nodes, where all nodes from the set are connected with at least q other nodes from the set)

returns None if impossible to calculate (e.g. vertex_count == 0 or q <= 1)

Example
use net_ensembles::EmptyNode;
use net_ensembles::Graph;

let graph: Graph<EmptyNode> = Graph::new(0);
assert_eq!(graph.q_core(1), None);
assert_eq!(graph.q_core(2), None);

let graph2: Graph<EmptyNode> = Graph::new(1);

assert_eq!(graph2.q_core(1), None);
assert_eq!(graph2.q_core(2), Some(0));


// create complete graph
let mut graph3: Graph<EmptyNode> = Graph::new(20);
for i in 0..graph3.vertex_count() {
    for j in i+1..graph3.vertex_count() {
        graph3.add_edge(i, j).unwrap();
    }
}

// since this is a complete graph, the q-core should always consist of 20 nodes
// as long as q < 20, as every node has 19 neighbors
for i in 2..20 {
    assert_eq!(graph3.q_core(i), Some(20));
}

assert_eq!(graph3.q_core(20), Some(0));
compute connected component ids
  • used for self.connected_components()
  • each vertex gets an id, all vertices with the same id are in the same connected component
  • returns (number of components, vector of ids)
compute sizes of all connected components
  • the number of connected components is the size of the returned vector, i.e. result.len()
  • returns empty vector, if graph does not contain vertices
  • returns (reverse) ordered vector of sizes of the connected components, i.e. the biggest component is of size result[0] and the smallest is of size result[result.len() - 1]

Count number of leaves in the graph, i.e. vertices with exactly one neighbor

👎 Deprecated since 0.3.0:

Please use any method of the Dot trait instead, e.g., dot_with_indices

  • Creates String which contains the topology of the network in a format that can be used by circo etc. to generate a pdf of the graph.
  • indices are used as labels
  • search for graphviz to learn about .dot format
👎 Deprecated since 0.3.0:

Please use any method of the DotExtra trait instead, e.g., dot_from_contained_index

Example
use std::fs::File;
use std::io::prelude::*;
use net_ensembles::{Graph, EmptyNode, dot_constants::EXAMPLE_DOT_OPTIONS};

let mut graph: Graph<EmptyNode> = Graph::new(3);
graph.add_edge(0, 1).unwrap();
graph.add_edge(0, 2).unwrap();
graph.add_edge(1, 2).unwrap();

// create string of dotfile
let s = graph.to_dot_with_labels_from_contained(
   EXAMPLE_DOT_OPTIONS,
   |_contained, index| format!("Hey {}!", index)
);

// write to file
let mut f = File::create("example.dot").expect("Unable to create file");
f.write_all(s.as_bytes()).expect("Unable to write data");

In this example, example.dot now contains:

graph G{
    bgcolor="transparent";
    fontsize=50;
    node [shape=ellipse, penwidth=1, fontname="Courier", pin=true ];
    splines=true;
    0 1 2 ;
    "0" [label="Hey 0!"];
    "1" [label="Hey 1!"];
    "2" [label="Hey 2!"];
    0 -- 1
    0 -- 2
    1 -- 2
}

Then you can use, e.g.,

foo@bar:~$ circo example.dot -Tpdf > example.pdf

to create a pdf representation from it. Search for graphviz to learn more.

👎 Deprecated since 0.3.0:

Please use any method of the DotExtra trait instead, e.g., dot_from_container_index

Same as to_dot_with_labels_from_contained but with access to neighbor information
Example
use std::fs::File;
use std::io::prelude::*;
use net_ensembles::traits::*;
use net_ensembles::dot_constants::*;
use net_ensembles::{Graph,EmptyNode};

let mut graph: Graph<EmptyNode> = Graph::new(5);
graph.add_edge(0, 1).unwrap();
graph.add_edge(0, 2).unwrap();
graph.add_edge(1, 2).unwrap();
graph.add_edge(0, 3).unwrap();
graph.add_edge(3, 4).unwrap();

// create string of dotfile
let s = graph.to_dot_with_labels_from_container(
    &[SPLINES, NO_OVERLAP].join("\n\t"),
    |container, index|
    {
        container.contained();  // does nothing in this example, but you can still access
                                // contained, as you could in
                                // to_dot_with_labels_from_contained
        format!("index {}, degree: {}", index, container.degree())
    }
);

// write to file
let mut f = File::create("example_2.dot").expect("Unable to create file");
f.write_all(s.as_bytes()).expect("Unable to write data");

In this example, example_2.dot now contains:

graph G{
    splines=true;
    overlap=false;
    0 1 2 3 4 ;
    "0" [label="index 0, degree: 3"];
    "1" [label="index 1, degree: 2"];
    "2" [label="index 2, degree: 2"];
    "3" [label="index 3, degree: 2"];
    "4" [label="index 4, degree: 1"];
    0 -- 1
    0 -- 2
    0 -- 3
    1 -- 2
    3 -- 4
}

Then you can use, e.g.,

foo@bar:~$ circo example_2.dot -Tpdf > example_2.pdf

to create a pdf representation from it. Search for graphviz to learn more.

  • returns None if graph not connected or does not contain any vertices
  • uses repeated breadth first search

calculate the size of the longest shortest path starting from vertex with index index using breadth first search

calculate sizes of all binode connected components
  • returns (reverse) ordered vector of sizes i.e. the biggest component is of size result[0] and the smallest is of size result[result.len() - 1]
  • destroys the underlying topology and therefore moves self
  • if you still need your graph, use self.clone().vertex_biconnected_components(false/true) for your calculations
Definition: vertex_biconnected_components(false)

Here, the (vertex) biconnected component of a graph is defined as maximal subset of nodes, where any one node could be removed and the remaining nodes would still be a connected component.

Note

Two vertices connected by an edge are considered to be biconnected, since after the removal of one vertex (and the corresponding edge), only one vertex remains. This vertex is in a connected component with itself.

Alternative Definition: vertex_biconnected_components(true)

If you want to use the alternative definition:

The biconnected component is defined as maximal subset of vertices, where each vertex can be reached by at least two node independent paths

The alternative definition just removes all 2s from the result vector.

Citations

I used the algorithm described in this paper:

J. Hobcroft and R. Tarjan, “Algorithm 447: Efficient Algorithms for Graph Manipulation” Commun. ACM, 16:372-378, 1973, DOI: 10.1145/362248.362272

You can also take a look at:

M. E. J. Newman, “Networks: an Introduction” Oxfort University Press, 2010, ISBN: 978-0-19-920665-0.

calculates vertex_load of all vertices in O(edges * vertices)
  • calculates the vertex_load for every vertex
  • defined as how many shortest paths pass through each vertex
variant
vertex_load(true)includes endpoints in calculation (for a complete graph with N vertices, every node will have vertex_load N - 1)
vertex_load(false)excludes endpoints in calculation (for a complete graph with N vertices, every node will have vertex_load 0)
Citations

I used the algorithm described in

M. E. J. Newman, “Scientific collaboration networks. II. Shortest paths, weighted networks, and centrality”, Phys. Rev. E 64, 016132, 2001, DOI: 10.1103/PhysRevE.64.016132

see also:

M. E. J. Newman, “Erratum: Scientific collaboration networks. II. Shortest paths, weighted networks, and centrality”, Phys. Rev. E 73, 039906, 2006, DOI: 10.1103/PhysRevE.73.039906

Calculates transitivity of graph
  • related to cluster coefficient (Note: transitivity and cluster coefficient are similar, but not necessarily equal)
  • returns NaN, if there are no paths of length two in the graph
Definition

transitivity = (number of closed paths of length two) / (number of paths of length two)

Citations

For the definition see for example:

M. E. J. Newman, “Networks: an Introduction” Oxfort University Press, 2010, ISBN: 978-0-19-920665-0.

Create a subgraph

Method to create a subgraph. node_list should contain all the indices corresponding to the nodes you want to keep, the order of the indices is irrelevant. Duplicate indices will be ignored. If any index is out of bounds (or node_list is empty), None will be returned

All edges between nodes that are inside the node_list will be kept. All other edges will be discarded. The nodes in the subgraph will get new indices corresponding to their new position. The contained information (T) will be cloned.

Note

The container used will be changed to a NodeContainer, since I cannot guarantee that other container would make sense here. E.g., if you used a SwContainer the information about the root edges might become invalid, because the corresponding nodes might not be part of the subgraph

Efficiently create a complete graph with n nodes

Reset small-world edge to its root state
  • panics if index out of bounds
  • in debug: panics if index0 == index1
Rewire edges
  • rewire edge (index0, index1) to (index0, index2)
panics
  • if indices are out of bounds
  • in debug: panics if index0 == index2
  • edge (index0, index1) has to be rooted at index0, else will panic in debug mode
How many nodes have long ranging edges?
  • counts how many nodes have long ranging edges
  • A long ranging edge is defined as an edge, where is_at_root returns true, i.e., which is not in ist original ring configuration
Fraction of nodes which have long ranging edges
  • A long ranging edge is defined as an edge, where is_at_root returns true, i.e., which is not in ist original ring configuration
How many long ranging edges are there in the Graph?
  • A long ranging edge is defined as an edge, where is_at_root returns true, i.e., which is not in ist original ring configuration
Fraction of long ranging edges in the Graph?
  • A long ranging edge is defined as an edge, where is_at_root returns false, i.e., which is not in ist original ring configuration
  • this is: #longranging/#total
Euclidean distance between two vertices
  • Calculates the distance between the vertices corresponding to the indices i and j
  • None if any of the indices is out of bounds

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

  • use function f to create labels depending on the index
  • for valid dot_options use dot_options! macro and take a look at module dot_constants
  • Read more

  • same as self.dot_from_indices but returns String instead
  • use index as labels for the nodes
  • default implementation uses dot_from_indices
  • Read more

  • same as self.dot_with_indices but returns String instead
  • create dot file with empty labels
  • default implementation uses dot_from_indices
  • Read more

  • same as self.dot(), but returns a String instead
  • create a dot representation
  • you can use the indices and the container A (usually stored at each index) to create the lables
  • Read more

  • create a dot representation
  • you can use the indices and T (usually something contained in A (see dot_from_container) and stored at each vertex) to create the lables
  • Read more

  • same as self.dot_string_from_container_index but returns String instead
  • create a dot representation
  • you can use the information of the container A (usually stored at each index) to create the lables
  • Read more

  • same as self.dot_from_container but returns String instead
  • same as self.dot_from_contained but returns String instead
  • create a dot representation
  • you can use T (usually something contained in A (see dot_from_container) and stored at each vertex) to create the lables
  • Read more

  • same as self.dot_from_contained but returns String
  • Performs the conversion.

  • get iterator over additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • similar to self.container_iter().map(|container| container.contained())
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over AdjContainer in order of the indices
  • iterator returns AdjContainer<Node>, i.e., A
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns (index_neighbor,&T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

    returns Iterator Read more

    returns Iterator Read more

    returns Iterator Read more

  • get iterator over additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • similar to self.container_iter().map(|container| container.contained())
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over AdjContainer in order of the indices
  • iterator returns AdjContainer<Node>, i.e., A
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns (index_neighbor,&T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

    returns Iterator Read more

    returns Iterator Read more

    returns Iterator Read more

  • get iterator over additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • similar to self.container_iter().map(|container| container.contained())
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns (index_neighbor,&T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over AdjContainer in order of the indices
  • iterator returns AdjContainer<Node>, i.e., A
  • Read more

  • iterate over additional information of neighbors of vertex index
  • iterator returns &T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

    returns Iterator Read more

    returns Iterator Read more

    returns Iterator Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

    calculates the average degree of the graph Read more

  • returns number of vertices adjacent to vertex index
  • None if index out of bounds
  • Read more

    compute sizes of all connected components Read more

  • returns None if graph not connected or does not contain any vertices
  • uses repeated breadth first search
  • Read more

    returns total number of edges in graph

    Count number of leaves in the graph, i.e. vertices with exactly one neighbor

    calculate the size of the longest shortest path starting from vertex with index index using breadth first search Read more

    definition Read more

    Calculates transitivity of graph Read more

    calculate sizes of all binode connected components Read more

    returns number of vertices present in graph

    Closely related (most of the time equal) to betweeness Read more

    Serialize this value into the given Serde serializer. Read more

    Sort adjecency lists

    If you depend on the order of the adjecency lists, you can sort them

    Performance
    • internally uses pattern-defeating quicksort as long as that is the standard
    • sorts an adjecency list with length d in worst-case: O(d log(d))
    • is called for each adjecency list, i.e., self.vertex_count() times

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

    Sort adjecency lists

    If you depend on the order of the adjecency lists, you can sort them

    Performance
    • internally uses pattern-defeating quicksort as long as that is the standard
    • sorts an adjecency list with length d in worst-case: O(d log(d))
    • is called for each adjecency list, i.e., self.vertex_count() times

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

  • sorts Adjecaency List
  • Sort adjecency lists

    If you depend on the order of the adjecency lists, you can sort them

    Performance
    • internally uses pattern-defeating quicksort as long as that is the standard
    • sorts an adjecency list with length d in worst-case: O(d log(d))
    • is called for each adjecency list, i.e., self.vertex_count() times

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

    Sort adjecency lists

    If you depend on the order of the adjecency lists, you can sort them

    Performance
    • internally uses pattern-defeating quicksort as long as that is the standard
    • sorts an adjecency list with length d in worst-case: O(d log(d))
    • is called for each adjecency list, i.e., self.vertex_count() times

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

  • sorts Adjecaency List
  • Auto Trait Implementations

    Blanket Implementations

    Gets the TypeId of self. Read more

    Immutably borrows from an owned value. Read more

    Mutably borrows from an owned value. Read more

    Cast from Self to T

    Try converting from Self to T

    Cast to integer, truncating Read more

    Cast to the nearest integer Read more

    Cast the floor to an integer Read more

    Cast the ceiling to an integer Read more

    Try converting to integer with truncation Read more

    Try converting to the nearest integer Read more

    Try converting the floor to an integer Read more

    Try convert the ceiling to an integer Read more

    Convert from T to Self

    Try converting from T to Self

    Performs the conversion.

    Performs the conversion.

    The alignment of pointer.

    The type for initializers.

    Initializes a with the given initializer. Read more

    Dereferences the given pointer. Read more

    Mutably dereferences the given pointer. Read more

    Drops the object pointed to by the given pointer. Read more

    The resulting type after obtaining ownership.

    Creates owned data from borrowed data, usually by cloning. Read more

    🔬 This is a nightly-only experimental API. (toowned_clone_into)

    Uses borrowed data to replace owned data, usually by cloning. Read more

    The type returned in the event of a conversion error.

    Performs the conversion.

    The type returned in the event of a conversion error.

    Performs the conversion.