Statistics
| Branch: | Revision:

## iof-tools / networkxMiCe / networkx-master / networkx / algorithms / tests / test_boundary.py @ 5cef0f13

 1 ```# test_boundary.py - unit tests for the boundary module ``` ```# ``` ```# Copyright 2015 NetworkX developers. ``` ```# ``` ```# This file is part of NetworkX. ``` ```# ``` ```# NetworkX is distributed under a BSD license; see LICENSE.txt for more ``` ```# information. ``` ```"""Unit tests for the :mod:`networkx.algorithms.boundary` module.""" ``` ```from __future__ import division ``` ```from itertools import combinations ``` ```from nose.tools import assert_almost_equals ``` ```from nose.tools import assert_equal ``` ```import networkx as nx ``` ```from networkx.testing.utils import * ``` ```from networkx import convert_node_labels_to_integers as cnlti ``` ```class TestNodeBoundary(object): ``` ``` """Unit tests for the :func:`~networkx.node_boundary` function.""" ``` ``` def test_null_graph(self): ``` ``` """Tests that the null graph has empty node boundaries.""" ``` ``` null = nx.null_graph() ``` ``` assert_equal(nx.node_boundary(null, []), set()) ``` ``` assert_equal(nx.node_boundary(null, [], []), set()) ``` ``` assert_equal(nx.node_boundary(null, [1, 2, 3]), set()) ``` ``` assert_equal(nx.node_boundary(null, [1, 2, 3], [4, 5, 6]), set()) ``` ``` assert_equal(nx.node_boundary(null, [1, 2, 3], [3, 4, 5]), set()) ``` ``` def test_path_graph(self): ``` ``` P10 = cnlti(nx.path_graph(10), first_label=1) ``` ``` assert_equal(nx.node_boundary(P10, []), set()) ``` ``` assert_equal(nx.node_boundary(P10, [], []), set()) ``` ``` assert_equal(nx.node_boundary(P10, [1, 2, 3]), {4}) ``` ``` assert_equal(nx.node_boundary(P10, [4, 5, 6]), {3, 7}) ``` ``` assert_equal(nx.node_boundary(P10, [3, 4, 5, 6, 7]), {2, 8}) ``` ``` assert_equal(nx.node_boundary(P10, [8, 9, 10]), {7}) ``` ``` assert_equal(nx.node_boundary(P10, [4, 5, 6], [9, 10]), set()) ``` ``` def test_complete_graph(self): ``` ``` K10 = cnlti(nx.complete_graph(10), first_label=1) ``` ``` assert_equal(nx.node_boundary(K10, []), set()) ``` ``` assert_equal(nx.node_boundary(K10, [], []), set()) ``` ``` assert_equal(nx.node_boundary(K10, [1, 2, 3]), {4, 5, 6, 7, 8, 9, 10}) ``` ``` assert_equal(nx.node_boundary(K10, [4, 5, 6]), {1, 2, 3, 7, 8, 9, 10}) ``` ``` assert_equal(nx.node_boundary(K10, [3, 4, 5, 6, 7]), {1, 2, 8, 9, 10}) ``` ``` assert_equal(nx.node_boundary(K10, [4, 5, 6], []), set()) ``` ``` assert_equal(nx.node_boundary(K10, K10), set()) ``` ``` assert_equal(nx.node_boundary(K10, [1, 2, 3], [3, 4, 5]), {4, 5}) ``` ``` def test_petersen(self): ``` ``` """Check boundaries in the petersen graph ``` ``` ``` ``` cheeger(G,k)=min(|bdy(S)|/|S| for |S|=k, 0