Beispiel #1
0
def test_sf():
    """
    Test the SF embedding.
    """
    graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)]

    model = SF(dimensions=8)

    model.fit(graphs)
    embedding = model.get_embedding()

    assert embedding.shape[0] == len(graphs)
    assert embedding.shape[1] == model.dimensions
    assert type(embedding) == np.ndarray

    graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)]

    model = SF(dimensions=128)

    model.fit(graphs)
    embedding = model.get_embedding()

    assert embedding.shape[0] == len(graphs)
    assert embedding.shape[1] == model.dimensions
    assert type(embedding) == np.ndarray
Beispiel #2
0
#------------------

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

model = Role2Vec()

model.fit(g)
model.get_embedding()

#------------
# SF example
#------------

graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)]

model = SF()

model.fit(graphs)
model.get_embedding()

#-----------------
# FSCNMF example
#-----------------

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

x = np.random.uniform(0, 1, (200, 200))

model = FSCNMF()

model.fit(g, x)
Beispiel #3
0
"""SF illustrative example."""

import networkx as nx
from karateclub.graph_embedding import SF

graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)]

model = SF()

model.fit(graphs)
model.get_embedding()
Beispiel #4
0
#-----------------------------------

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

model = Role2Vec()

model.fit(g)
model.get_embedding()

#-----------------------------------
# SF example
#-----------------------------------

graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)]

model = SF()

model.fit(graphs)
model.get_embedding()

#-----------------------------------
# FSCNMF example
#-----------------------------------

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

x = np.random.uniform(0, 1, (200, 200))

model = FSCNMF()

model.fit(g, x)