~ubuntu-branches/ubuntu/utopic/python-networkx/utopic

« back to all changes in this revision

Viewing changes to networkx/algorithms/approximation/tests/test_ramsey.py

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2012-08-11 12:41:30 UTC
  • mfrom: (1.4.1) (5.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20120811124130-whr6uso7fncyg8bi
Tags: 1.7-1
* New upstream release
* debian/patches/changeset_*
  - removed, included upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from nose.tools import *
 
2
import networkx as nx
 
3
import networkx.algorithms.approximation as apxa
 
4
 
 
5
def test_ramsey():
 
6
    # this should only find the complete graph
 
7
    graph = nx.complete_graph(10)
 
8
    c, i = apxa.ramsey_R2(graph)
 
9
    cdens = nx.density(graph.subgraph(c))
 
10
    eq_(cdens, 1.0, "clique not found by ramsey!")
 
11
    idens = nx.density(graph.subgraph(i))
 
12
    eq_(idens, 0.0, "i-set not found by ramsey!")
 
13
 
 
14
    # this trival graph has no cliques. should just find i-sets
 
15
    graph = nx.trivial_graph(nx.Graph())
 
16
    c, i = apxa.ramsey_R2(graph)
 
17
    cdens = nx.density(graph.subgraph(c))
 
18
    eq_(cdens, 0.0, "clique not found by ramsey!")
 
19
    idens = nx.density(graph.subgraph(i))
 
20
    eq_(idens, 0.0, "i-set not found by ramsey!")
 
21
 
 
22
    graph = nx.barbell_graph(10, 5, nx.Graph())
 
23
    c, i = apxa.ramsey_R2(graph)
 
24
    cdens = nx.density(graph.subgraph(c))
 
25
    eq_(cdens, 1.0, "clique not found by ramsey!")
 
26
    idens = nx.density(graph.subgraph(i))
 
27
    eq_(idens, 0.0, "i-set not found by ramsey!")