示例#1
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.generators.small

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.generators.small)
示例#2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.utils.decorators

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.utils.decorators)
示例#3
0
import networkx.algorithms.assortativity.tests.test_neighbor_degree
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.assortativity.tests.test_neighbor_degree,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#4
0
import networkx.algorithms.link_analysis.tests.test_hits
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.link_analysis.tests.test_hits,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.generators.line

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.generators.line)
示例#6
0
import networkx.algorithms.shortest_paths.tests.test_generic
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.shortest_paths.tests.test_generic,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#7
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.generators.degree_seq

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.generators.degree_seq)
示例#8
0
# This file is part of NetworkX.
#
# NetworkX is distributed under a BSD license; see LICENSE.txt for more
# information.
#

import networkx.readwrite.edgelist
from networkx.readwrite.edgelist import parse_edgelist as _parse_edgelist
from networkx.readwrite.edgelist import read_edgelist as _read_edgelist
from networkx.utils.decorators import open_file

from graphscope.experimental import nx
from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx
from graphscope.experimental.nx.utils.compat import patch_docstring

import_as_graphscope_nx(networkx.readwrite.edgelist)


@patch_docstring(_parse_edgelist)
def parse_edgelist(
    lines, comments="#", delimiter=None, create_using=None, nodetype=None, data=True
):
    from ast import literal_eval

    G = nx.empty_graph(0, create_using)
    edges = []
    for line in lines:
        p = line.find(comments)
        if p >= 0:
            line = line[:p]
        if not len(line):
示例#9
0
import networkx.algorithms.node_classification.tests.test_harmonic_function
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.node_classification.tests.test_harmonic_function,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#10
0
import networkx.algorithms.components.tests.test_semiconnected
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx
from graphscope.experimental.nx.utils.compat import with_graphscope_nx_context

import_as_graphscope_nx(
    networkx.algorithms.components.tests.test_semiconnected,
    decorators=pytest.mark.usefixtures("graphscope_session"))

from networkx.algorithms.components.tests.test_semiconnected import TestIsSemiconnected


@pytest.mark.usefixtures("graphscope_session")
@with_graphscope_nx_context(TestIsSemiconnected)
class TestIsSemiconnected():
    def test_undirected(self):
        pytest.raises(nx.NetworkXNotImplemented, nx.is_semiconnected,
                      nx.Graph())

    def test_empty(self):
        pytest.raises(nx.NetworkXPointlessConcept, nx.is_semiconnected,
                      nx.DiGraph())
示例#11
0
import networkx.algorithms.node_classification.tests.test_local_and_global_consistency
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.node_classification.tests.
    test_local_and_global_consistency,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
GraphScope's compatible layer for :mod:`networkx.relabel`.
"""

import networkx.relabel

from graphscope.experimental import nx
from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.relabel)
示例#13
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.generators.community

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.generators.community)
示例#14
0
import networkx.algorithms.centrality.tests.test_dispersion
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.centrality.tests.test_dispersion,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#15
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.utils.misc

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.utils.misc)
import networkx.algorithms.tests.test_distance_regular
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.tests.test_distance_regular,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#17
0
import networkx.algorithms.centrality.tests.test_current_flow_betweenness_centrality_subset
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.centrality.tests.
    test_current_flow_betweenness_centrality_subset,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#18
0
import networkx.algorithms.approximation.tests.test_treewidth
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.algorithms.approximation.tests.test_treewidth,
                        decorators=pytest.mark.usefixtures("graphscope_session"))
示例#19
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import networkx.generators.trees

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.generators.trees)
示例#20
0
import networkx.algorithms.community.tests.test_quality
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.community.tests.test_quality,
    decorators=pytest.mark.usefixtures("graphscope_session"))
import networkx.algorithms.isomorphism.tests.test_temporalisomorphvf2
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.isomorphism.tests.test_temporalisomorphvf2,
    decorators=pytest.mark.usefixtures("graphscope_session"))


@pytest.mark.skip(reason="not supoort time object as attribute")
class TestTimeRespectingGraphMatcher(object):
    pass


@pytest.mark.skip(reason="not supoort time object as attribute")
class TestDiTimeRespectingGraphMatcher(object):
    pass
示例#22
0
# NetworkX is distributed under a BSD license; see LICENSE.txt for more
# information.
#

import warnings

import networkx.convert
from networkx.convert import from_dict_of_dicts
from networkx.convert import from_dict_of_lists
from networkx.convert import from_edgelist

from graphscope.experimental import nx
from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx
from graphscope.framework.dag_utils import arrow_to_dynamic

import_as_graphscope_nx(networkx.convert)


def to_nx_graph(data, create_using=None, multigraph_input=False):  # noqa: C901
    """Make a graph from a known data structure.

    The preferred way to call this is automatically
    from the class constructor

    >>> d = {0: {1: {'weight':1}}} # dict-of-dicts single edge (0,1)
    >>> G = nx.Graph(d)

    instead of the equivalent

    >>> G = nx.from_dict_of_dicts(d)
示例#23
0
import networkx.algorithms.flow.tests.test_maxflow_large_graph
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx
from graphscope.experimental.nx.utils.compat import with_graphscope_nx_context

import_as_graphscope_nx(
    networkx.algorithms.flow.tests.test_maxflow_large_graph,
    decorators=pytest.mark.usefixtures("graphscope_session"))

from networkx.algorithms.flow.tests.test_maxflow_large_graph import \
    TestMaxflowLargeGraph


@pytest.mark.usefixtures("graphscope_session")
@with_graphscope_nx_context(TestMaxflowLargeGraph)
class TestMaxflowLargeGraph():
    @pytest.mark.skip(reason="not support tuple as node")
    def test_pyramid(self):
        pass

    @pytest.mark.skip(reason="not support read_gpickle")
    def test_gl1(self):
        pass

    @pytest.mark.skip(reason="not support read_gpickle")
    def test_gw1(self):
        pass

    @pytest.mark.skip(reason="not support read_gpickle")
    def test_wlm3(self):
示例#24
0
import networkx.algorithms.tests.test_minors
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(networkx.algorithms.tests.test_minors,
                        decorators=pytest.mark.usefixtures("graphscope_session"))


@pytest.mark.skip(reason="not support Graph object as node.")
class TestQuotient(object):
    pass


@pytest.mark.skip(reason="not support Graph object as node.")
class TestContraction(object):
    pass
示例#25
0
import networkx.algorithms.bipartite.tests.test_centrality
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.bipartite.tests.test_centrality,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#26
0
import networkx.algorithms.traversal.tests.test_beamsearch
import pytest

from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx

import_as_graphscope_nx(
    networkx.algorithms.traversal.tests.test_beamsearch,
    decorators=pytest.mark.usefixtures("graphscope_session"))
示例#27
0
# All rights reserved.
#
# This file is part of NetworkX.
#
# NetworkX is distributed under a BSD license; see LICENSE.txt for more
# information.
#

import networkx.convert_matrix
from networkx.convert_matrix import from_pandas_edgelist as _from_pandas_edgelist

from graphscope.experimental import nx
from graphscope.experimental.nx.utils.compat import import_as_graphscope_nx
from graphscope.experimental.nx.utils.compat import patch_docstring

import_as_graphscope_nx(networkx.convert_matrix)


@patch_docstring(_from_pandas_edgelist)
def from_pandas_edgelist(df,
                         source="source",
                         target="target",
                         edge_attr=None,
                         create_using=None):
    g = nx.empty_graph(0, create_using)

    if edge_attr is None:
        g.add_edges_from(zip(df[source], df[target]))
        return g

    # Additional columns requested