Graph operations#
Edge induced subgraphs#
- edge_induced_subgraph(net, edges)#
Returns a copy of a subset of the network net
consisting only of edges
edges
and all their incident vertices.
Vertex induced subgraphs#
- vertex_induced_subgraph(net, verts)#
Returns a copy of a subset of the network net
consisting only of vertices
verts
and any edges with all incident vertices in verts
.
Adding and removings edges#
- with_edges(network, edges)#
Returns a copy of net
with edges from edges
along with all their
incident vertices added in.
- without_edges(network, edges)#
Returns a copy of net
with edges from edges
removed. The returned
graph has all the vertices of the original graph.
- occupy_edges(network, prob_func: Callable[[network.edge_type()], float], random_state)#
Return a copy of the network with the same set of vertices, but with each edge
kept with probability determined by calling the function prob_func
, or
occupation_prob
in C++.
- occupy_edges(network, prob_map: dict[network.edge_type(), float], random_state, default_prob: float = 0.0)
Return a copy of the network with the same set of vertices, but with each edge
kept with probability determined by looking up the edge in the dictionary
prob_map
. If the edge is not in the map, the value default_prob
is
determines the probability of the edge being present in the output network.
- uniformly_occupy_edges(network, occupation_prob: float, random_state)#
Return a copy of the network with the same set of vertices, but with each edge
kept with probability determined by the parameter occupation_prob
.
Adding and removing vertices#
- with_vertices(network, verts)#
Returns a copy of net
with vertices from verts
added in.
- without_vertices(network, verts)#
Returns a copy of net
with vertices from verts
, along with all
their incident edges removed.
- occupy_vertices(network, prob_func: Callable[[network.vertex_type()], float], random_state)#
-
template<network_edge EdgeT, std::invocable<const typename EdgeT::VertexType&> ProbFun, std::uniform_random_bit_generator Gen>
requires std::convertible_to<std::invoke_result_t<ProbFun, const typename EdgeT::VertexType&>, double>
network<EdgeT> occupy_vertices(const network<EdgeT> &g, ProbFun &&occupation_prob, Gen &gen)#
Return a copy of the network with each vertex (and all its incident edges)
kept with probability determined by calling the function prob_func
, or
occupation_prob
in C++, with that vertex.
- occupy_vertices(network, prob_map: dict[network.vertex_type(), float], random_state, default_prob: float = 0.0)
Return a copy of the network with each vertex kept with probability determined
by looking up the vertex in the dictionary prob_map
. If the vertex is not
in the map, the value default_prob
is determines the probability of the
vertex being present in the output network.
- uniformly_occupy_vertices(network, occupation_prob: float, random_state)#
Return a copy of the network with each vertex kept with probability determined
by the parameter occupation_prob
.
Graph Union#
- graph_union(g1, g2)#
Calculates the graph union of two networks g1
and g2
: a new
network containing the union of their sets of vertices and edges.
Cartesian Product#
- cartesian_product(g1: undirected_network[vertex_type1], g2: undirected_network[vertex_type2]) undirected_network[pair[vertex_type1, vertex_type2]] #
-
template<network_vertex VertT1, network_vertex VertT2>
undirected_network<std::pair<VertT1, VertT2>> cartesian_product(const undirected_network<VertT1> &g1, const undirected_network<VertT2> &g2)#
Calculates graph cartesian product of two undirected networks g1
and
g1
.
Note
While in C++ there are no limits on the types of vertices
of the network (as long as they satisfy network_vertex
)
the Python binding only supports certain vertex types.
This function is not implemented for cases that would produce output vertices
too complex to be predefined, i.e., when vertex_type1
or
vertex_type2
are not a simple numerical or string type. In these cases
you might want to relabel the vertices of the networks before calling this
function.
Relabling vertices#
Warning
Experimental API. We are still trying to find the right balance with these functions. The function name, parameters and available variations will probably change in the future versions.