Esempio n. 1
0
def test_geoscattering():
    """
    Test the GeoScattering embedding.
    """
    graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(10)]

    for order in range(4, 20):
        for moment in range(4, 7):

            model = GeoScattering(order=order, moments=moment)

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

            first_block = 3*model.order
            second_block = 3*(model.order+1)*(model.moments-1)
            third_block = 3*(model.order-1)*model.order*(model.moments-1)/2

            feature_count = first_block+second_block+third_block
    
            assert embedding.shape[0] == len(graphs)
            assert embedding.shape[1] == feature_count
Esempio n. 2
0
#----------------

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

model = GEMSEC()

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

#-------------------------------
# Geometric Scattering example
#-------------------------------

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

model = GeoScattering()

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

#--------------------
# NodeSketch example
#--------------------

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

model = NodeSketch()

model.fit(g)
embedding = model.get_embedding()
Esempio n. 3
0
"""GeoScattering illustrative example."""

import networkx as nx
from karateclub.graph_embedding import GeoScattering

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

model = GeoScattering()

model.fit(graphs)
model.get_embedding()