def test_adjacency_matrix():
    g = nx.barbell_graph(8, 5)
    cc_ = CreateCliqueComplex(g)
    adjacency = nx.adjacency_matrix(g)

    assert_almost_equal(adjacency.todense(),
                        cc_.get_adjacent_matrix().todense())
def test_input_distance_matrix():
    dist = distance_matrix(X, X, p=2)

    cc_ = CreateCliqueComplex(data=dist, alpha=alpha, data_type='matrix')
    cd_ = cc_.create_complex_from_graph()

    lap_cc = CreateLaplacianMatrices().fit(cd,
                                           (0, )).transform(cd)[0].todense()
    lap_cc_ = CreateLaplacianMatrices().fit(cd_,
                                            (0, )).transform(cd_)[0].todense()

    assert_almost_equal(lap_cc, lap_cc_)
Exemple #3
0
def compute_node_edge_entropy(g, i, taus_n, taus_e):
    cd = CreateCliqueComplex(graph=g).create_complex_from_graph()
    lap = CreateLaplacianMatrices().fit_transform(cd, (0, 1))
    n_diff = HeatDiffusion().fit_transform(lap[0], taus_n)
    e_diff = HeatDiffusion().fit_transform(lap[1], taus_e)
    mh_n = GraphEntropy().fit_transform(n_diff).T
    mh_e = GraphEntropy().fit_transform(e_diff).T

    if i % 10000 == 0:
        print(
            "Atoms and Bonds of {} molecules have been embedded...".format(i))

    return [mh_n, mh_e]
def test_data_input_with__graph_data_type():

    with pytest.raises(ValueError):
        CreateCliqueComplex(data=X, alpha=alpha)
def test_graph_input_with_data_type():

    with pytest.raises(ValueError):
        CreateCliqueComplex(graph=nx.barbell_graph(10, 10), data_type='cloud')
import numpy as np
import pytest
import networkx as nx

from sklearn.exceptions import NotFittedError
from giotto.graphs.create_clique_complex import CreateCliqueComplex,\
    CreateLaplacianMatrices, CreateBoundaryMatrices

from numpy.testing import assert_almost_equal
from scipy.spatial import distance_matrix

X = np.random.random((10, 2))
alpha = 0.4
cc = CreateCliqueComplex(data=X, alpha=alpha, data_type='cloud')
cd = cc.create_complex_from_graph()


def test_graph_input_with_data_type():

    with pytest.raises(ValueError):
        CreateCliqueComplex(graph=nx.barbell_graph(10, 10), data_type='cloud')


def test_data_input_with__graph_data_type():

    with pytest.raises(ValueError):
        CreateCliqueComplex(data=X, alpha=alpha)


def test_input_distance_matrix():
    dist = distance_matrix(X, X, p=2)