On 16.03.2015 02:18, dushyanthbn wrote:
> How can I find the number of immediate common neighbors between all the nodes
> in a given graph and represent it as a matrix. i have attached the graph.
> Please provide some inputs. connectivity11.gz
> <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4026036/connectivity11.gz>

m = zeros((g.num_vertices(), g.num_vertices()))

for v in g.vertices():
    nv = set(v.all_neighbours())
    for w in g.vertices():
        nw = set(w.all_neighbours())
        m[v, w] = len(nv.intersection(nw))


-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to