How to create a graph between nodes based on their common neighbour (or connection). Suppose, A is connected to B, B is connected to C. Then how to connect A-C and produce a graph, as B is common for both.
You can use connect.neighborhood
to add the A-C connection to the existing graph.
The operation you describe is called graph power as it’s related to powers of the adjacency matrix.
If you only want A-C, but not A-B and B-C, then get the (sparse) adjacency matrix, take its 2nd power, then convert it back to a graph.
You could also use cocitation
or bibcoupling
as an alternative. Note that those functions return matrices, which you can convert back into a graph:
G2 = graph_from_adjacency_matrix(cocitation(G), mode="undirected")
where G
is the original graph of course.