コード例 #1
0
def test_edmot():
    """
    Test the EdMot procedure.
    """
    graph = nx.newman_watts_strogatz_graph(50, 5, 0.3)

    model = EdMot()

    model.fit(graph)
    memberships = model.get_memberships()

    indices = [k for k, v in memberships.items()].sort()
    nodes = [node for node in graph.nodes()].sort()

    assert graph.number_of_nodes() == len(memberships)
    assert indices == nodes
    assert type(memberships) == dict

    graph = nx.newman_watts_strogatz_graph(150, 5, 0.3)

    model = EdMot()

    model.fit(graph)
    memberships = model.get_memberships()

    indices = [k for k, v in memberships.items()].sort()
    nodes = [node for node in graph.nodes()].sort()

    assert graph.number_of_nodes() == len(memberships)
    assert indices == nodes
    assert type(memberships) == dict
コード例 #2
0
for num in nums:
    reader = GraphReader("twitch%s" % num)
    graph = reader.get_graph()
    target = reader.get_target()
    d = {}
    model = LabelPropagation()
    comms = run(model, graph)
    coeffs = []
    for key in sorted(comms.keys()):
        sub = graph.subgraph(list(comms[key]))
        coeff = nx.average_clustering(sub)
        coeffs.append(coeff)
    avg_coeff = sum(coeffs) / len(coeffs)
    d['label'] = avg_coeff

    model = EdMot()
    comms = run(model, graph)
    coeffs = []
    for key in sorted(comms.keys()):
        sub = graph.subgraph(list(comms[key]))
        coeff = nx.average_clustering(sub)
        coeffs.append(coeff)
    avg_coeff = sum(coeffs) / len(coeffs)
    d['edmot'] = avg_coeff

    model = GEMSEC()
    comms = run(model, graph)
    coeffs = []
    for key in sorted(comms.keys()):
        sub = graph.subgraph(list(comms[key]))
        coeff = nx.average_clustering(sub)
コード例 #3
0
# Splitter example
#-------------------

g = nx.newman_watts_strogatz_graph(100, 20, 0.05)

model = EgoNetSplitter(1.0)

model.fit(g)

#----------------
# Edmot example
#----------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.9)

model = EdMot(3, 0.5)

model.fit(g)

#----------------
# DANMF example
#----------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.02)

model = DANMF()

model.fit(g)

#----------------
# M-NMF example
コード例 #4
0
"""EdMot example."""

import networkx as nx
from karateclub.community_detection.non_overlapping import EdMot

g = nx.newman_watts_strogatz_graph(100, 20, 0.05)

model = EdMot()

model.fit(g)
コード例 #5
0
ファイル: examples.py プロジェクト: kmkwon94/comcomai
def edmot(population, neighbors, probability):
    g = nx.newman_watts_strogatz_graph(population, neighbors, probability)
    model = EdMot(3, 0.5)
    model.fit(g)
    #print(model.get_memberships())
    return [model.get_memberships()]
コード例 #6
0
from karateclub.node_embedding.neighbourhood import GraRep, DeepWalk, Walklets, NMFADMM, Diff2Vec, BoostNE, NetMF
from karateclub.community_detection.overlapping import EgoNetSplitter, NNSED, DANMF, MNMF, BigClam, SymmNMF
from karateclub.community_detection.non_overlapping import EdMot, LabelPropagation, SCD
from karateclub.graph_embedding import Graph2Vec, FGSD, GL2Vec, SF
from karateclub.node_embedding.attributed import BANE, TENE, TADW, FSCNMF, SINE, MUSAE
from karateclub.node_embedding.structural import GraphWave, Role2Vec
from karateclub.dataset import GraphReader, GraphSetReader

#------------------------------------
# Edmot example
#------------------------------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.1)

model = EdMot(3, 4)

model.fit(g)

#------------------------------------
# MUSAE example
#------------------------------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.2)

X = {i: random.sample(range(150), 50) for i in range(100)}

row = np.array([k for k, v in X.items() for val in v])
col = np.array([val for k, v in X.items() for val in v])
data = np.ones(100 * 50)
shape = (100, 150)