1
from nose.tools import *
3
import networkx.algorithms.approximation as apxa
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!")
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!")
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!")