Transform – Graph Transformation

Module for graph transformation utilities.

line_graph(g[, backtracking, shared]) Return the line graph of this graph.
reverse(g[, share_ndata, share_edata]) Return the reverse of a graph
to_simple_graph(g) Convert the graph to a simple graph with no multi-edge.
to_bidirected(g[, readonly]) Convert the graph to a bidirected graph.
khop_adj(g, k) Return the matrix of \(A^k\) where \(A\) is the adjacency matrix of \(g\), where a row represents the destination and a column represents the source.
khop_graph(g, k) Return the graph that includes all \(k\)-hop neighbors of the given graph as edges.
laplacian_lambda_max(g) Return the largest eigenvalue of the normalized symmetric laplacian of g.
knn_graph(x, k) Transforms the given point set to a directed graph, whose coordinates are given as a matrix.
segmented_knn_graph(x, k, segs) Transforms the given point set to a directed graph, whose coordinates are given as a matrix.
add_self_loop(g) Return a new graph containing all the edges in the input graph plus self loops of every nodes.
remove_self_loop(g) Return a new graph with all self-loop edges removed
metapath_reachable_graph(g, metapath) Return a graph where the successors of any node u are nodes reachable from u by the given metapath.