Пример #1
0
def test_text(graph, quoting, verbose):
    g = cfpq_data.graph_from_text(graph, verbose=verbose)
    text = cfpq_data.graph_to_text(g, quoting=quoting, verbose=verbose)
    gin = cfpq_data.graph_from_text(text, verbose=verbose)

    assert (
        g.number_of_nodes() == gin.number_of_nodes()
        and g.number_of_edges() == gin.number_of_edges()
    )
Пример #2
0
def test_text_format():
    with pytest.raises(ValueError):
        cfpq_data.graph_from_text("1 2 3 4")
Пример #3
0
from itertools import product
import os
import random

import networkx as nx
import pytest

import cfpq_data

seed = 42
random.seed(seed)

g1 = cfpq_data.labeled_binomial_graph(42, 0.42, seed=seed, verbose=False)
g2 = cfpq_data.labeled_binomial_graph(42, 0.73, seed=seed, verbose=False)
g3 = cfpq_data.graph_from_text("1 2", verbose=False)
g4 = nx.path_graph(42, create_using=nx.MultiDiGraph)


@pytest.mark.parametrize(
    "graph, quoting, verbose",
    list(
        product(
            [
                g1,
                g2,
                g3,
                g4,
            ],
            [True, False],
            [True, False],
        )
Пример #4
0
import pytest

import cfpq_data

g1 = cfpq_data.graph_from_text("1 A 2", verbose=False)
g2 = cfpq_data.labeled_two_cycles_graph(42,
                                        28,
                                        edge_labels=("x", "y"),
                                        verbose=False)
g3 = cfpq_data.graph_from_text("1 2\n3", verbose=False)


@pytest.mark.parametrize(
    "graph,expected_labels",
    [
        (g1, {"A"}),
        (g2, {"x", "y"}),
        (g3, set()),
    ],
)
def test_get_labels(graph, expected_labels):
    assert cfpq_data.get_labels(graph, verbose=False) == expected_labels