🔏
Tobigs Graph Study
  • Tobigs Graph Study
  • Chapter1. Machine Learning with Graphs
    • Python code - graph basic
  • Chapter2. Properties of Networks, Random Graph Models
    • Python code - kronecker product
  • Chapter3. Motifs and Structural Roles in Networks
    • Python code - RoIX & ESU Tree
  • Chapter4. Community Structure in Networks
  • Chapter5. Spectral Clustering
  • Chapter6. Message Passing and Node Classification
  • Chapter7. Graph Representation Learning
  • Chapter8. Graph Neural Networks
  • Chapter9. Graph Neural Networks:Hands-on Session
  • Chapter10. Deep Generative Models for Graphs
  • Chapter11. Link Analysis: PageRank
  • Chapter12. Network Effects and Cascading Behavior
  • Chapter13. Probabilistic Contagion and Models of influnce
  • Chapter14. Influence Maximization in Networks
  • Chapter15. Outbreak Detection in Networks
  • Chapter16. network evolution graph
  • Chapter17. Reasoning over Knowledge Graphs
  • Chapter18. Limitations of Graph Neural Networks
  • Chapter19. Applications of Graph Neural Networks
Powered by GitBook
On this page
  • RoIX
  • ESU Tree

Was this helpful?

  1. Chapter3. Motifs and Structural Roles in Networks

Python code - RoIX & ESU Tree

PreviousChapter3. Motifs and Structural Roles in NetworksNextChapter4. Community Structure in Networks

Last updated 5 years ago

Was this helpful?

RoIX

ESU Tree


def EnumerateSubgraphs(G, k):
  N = len(G)
  visited = [False] * N
  queue = []
  ans = 0
  sub = {}
  sub_graph = {}
  for i in range(N):
    queue.append([i])
  while queue:
    front = queue[0]
    queue = queue[1:]
    if len(front)==k:
      degree = [0] * N
      for f in front:
        for j in front:
          if G[f][j]==1:
            degree[f] += 1
            degree[j] += 1
      if len(set(front)) != len(front):
        continue
      if str(sorted(front)) in sub_graph:
        continue
      sub_graph[str(sorted(front))] = 1
      if str(sorted(degree)) in sub:
        sub[str(sorted(degree))] += 1 
      else:
        sub[str(sorted(degree))] = 1
      print(front)
      continue
    for i in range(N):
      if G[front[-1]][i]==1 and i > front[0]:
        queue.append(front+[i])
  for s in sub:
    ans += sub[s]
  return ans
      
  

G_adj = [[0, 0, 1, 0, 0],[0, 0, 1, 0, 0],[1, 1, 0, 1, 1],[0, 0, 1, 0, 1],[0, 0, 1, 1, 0]]
print("Start!")
ans = EnumerateSubgraphs(G_adj, k=5)
print(ans)

GitHub - benedekrozemberczki/RolX: An alternative implementation of Recursive Feature and Role Extraction (KDD11 & KDD12)GitHub
Logo