0

I would like to count the number of the full 3-node subgraphs. Nodes of the original graph have names. The example code is below.

g <- graph.full(n=5, directed = TRUE)

# adjacency matrices 
d3<-matrix(c(0,1,1,1,0,1,1,1,0),nrow=3,ncol=3)

# Turn them into a convenient list
sbgDouble.mat<-list(d3)

# And then into a list of graph objects
sbgDouble.graph<-lapply(sbgDouble.mat, graph.adjacency)

# Count the number of the full 3-node subgraph

subgraph.freq.g<-c()

subgraph.freq.g[1]<-
graph.count.subisomorphisms.vf2(g, sbgDouble.graph[[1]])

#> subgraph.freq.g
# [1]  60

Update: I have tried graph.get.isomorphisms.vf2(g, sbgDouble.graph[[1]]) but result is list().

Could some one please say me how to output the names/ids list of nodes for 3-node subgraph? Thanks.

Nick
  • 1,086
  • 7
  • 21

1 Answers1

0

in order to see vertex IDs we can use the function graph.get.subisomorphisms.vf2(), for example,

graph.get.subisomorphisms.vf2(g, sbgDouble.graph[[1]])[1]
[[1]]
+ 3/5 vertices:
[1] 1 2 3
Nick
  • 1,086
  • 7
  • 21