Ejemplo n.º 1
0
def GraphModelWithoutOverlaps(mu=0.2):
    ''' Trochu propojene komunity: mu = 0.2 '''
    K = 3
    omega = np.array([[1 - mu, mu, 0], [mu, 1 - 2 * mu, mu], [0, mu, 1 - mu]])
    N = 100
    membership = [np.random.randint(K) for _ in range(N)]
    G = np.array([[int(membership[n] == k) for n in range(N)] for k in range(K)])
    model = Model(G, omega)
    return model
Ejemplo n.º 2
0
def GrafWithoutOverlaps(mu=0.2):
    ''' Trochu propojene komunity: mu = 0.2 '''
    K = 3
    omega = np.array([[1 - mu, mu, 0], [mu, 1 - 2 * mu, mu], [0, mu, 1 - mu]])
    N = 100
    membership = [np.random.randint(K) for _ in range(N)]
    G = np.array([[int(membership[n] == k) for n in range(N)]
                  for k in range(K)])
    model = Model(G, omega)
    generateDetectAndSave(model, 'bezPrekryvu.gexf')
Ejemplo n.º 3
0
def GrafBezPrekryvuIzolovane():
    ''' komunity jsou komponenty souvislosti: mu = 0 '''
    K = 3
    omega = np.eye(K, K)
    N = 100
    membership = [np.random.randint(K) for _ in range(N)]
    G = np.array([[int(membership[n] == k) for n in range(N)]
                  for k in range(K)])
    model = Model(G, omega)
    generateDetectAndSave(model, 'bezPrekryvuIzolovane.gexf')
Ejemplo n.º 4
0
def generateDetectAndSave(model: Model, fileName):
    graph = Generator(model).next()

    olapSBMmax, olapSBM = service.olapSBM(graph, 6, 50)
    memberships = dict(bigClam=service.bigClam(graph),
                       louvain=service.louvain(graph),
                       olapSBMmax=olapSBMmax,
                       olapSBM=olapSBM,
                       biSBM=service.biSBM(graph))

    evaluations = dict()
    for method in memberships:
        appendMemberships(graph, memberships[method], method)
        evaluations[method] = Evaluator(model.getMemberships(),
                                        memberships[method]).evaluate()

    record = dict(graph=fileName, evaluations=evaluations)
    recordEvaluation(record)

    nx.write_gexf(graph, output(fileName))
Ejemplo n.º 5
0
 def getModel(self) -> Model:
     G = self._getGroupMatrix()
     omega = self._getCommunityMatrix()
     model = Model(G, omega)
     return model
Ejemplo n.º 6
0
def getComsBiNum(model: Model):
    if isinstance(model, BipartitniModel):
        return (model.get_num_coms_type_a(), model.get_num_coms_type_b())
    else: return (model.get_num_coms(), 0)