예제 #1
0
파일: bd.py 프로젝트: yawara/gbc
def bd(n):
  G = gbc(n)
  H = to_hg(G)
  
  return H
예제 #2
0
def count_triangles(n):
  g = gbc(n)
  m = nx.to_numpy_matrix(g)
  m3 = m.dot(m).dot(m)
  return np.diag(m3)//2
예제 #3
0
파일: bd.py 프로젝트: yawara/gbc
import networkx as nx
from networkx.algorithms import bipartite
from gbc_without_sage import gbc_with_loop as gbc

G = gbc(2)

def check_dup(G):
  for i, v in enumerate(G):
    for j, w in enumerate(G):
      if i < j:
        if set(G.neighbors(v)) == set(G.neighbors(w)):
          raise Exception("Found duplicated nodes")

def check_neighbors(G):
  check_dup(G)
  rtv = set()
  for i, v in enumerate(G):
    for j, w in enumerate(G):
      if i < j:
        l = len(set(G.neighbors(v)).intersection(G.neighbors(w)))
        print(l)
        rtv.add(l)
  print(rtv)
  
def to_hg(G):
  check_dup(G)
  
  H = nx.Graph()
  
  for v in G:
    H.add_node(v, bipartite=0)