# Python code  - RoIX & ESU Tree

## RoIX

{% embed url="<https://github.com/benedekrozemberczki/RolX>" %}

## ESU Tree

```python

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)


```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tobigs.gitbook.io/tobigs-graph-study/chapter3./python-code-roix-and-esu-tree.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
