Skip to content

Commit 49fc54b

Browse files
authored
Merge pull request #1043 from Axelrod-Python/reconcile-moran-b
Reconcile Moran processes
2 parents 09a2206 + ce39975 commit 49fc54b

File tree

7 files changed

+448
-285
lines changed

7 files changed

+448
-285
lines changed

axelrod/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
update_history, update_state_distribution, Player)
1717
from .mock_player import MockPlayer
1818
from .match import Match
19-
from .moran import MoranProcess, MoranProcessGraph, ApproximateMoranProcess
19+
from .moran import MoranProcess, ApproximateMoranProcess
2020
from .strategies import *
2121
from .deterministic_cache import DeterministicCache
2222
from .match_generator import *

axelrod/graph.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def add_edges(self, edges):
4747
for edge in edges:
4848
self.add_edge(*edge)
4949

50+
def add_loops(self):
51+
"""
52+
Add all loops to edges
53+
"""
54+
self.add_edges((i, i) for i, _ in enumerate(self.vertices()))
55+
5056
def edges(self):
5157
return self._edges
5258

@@ -116,13 +122,14 @@ def complete_graph(length, loops=True):
116122
-------
117123
a Graph object
118124
"""
119-
offset = 1
120-
if loops:
121-
offset = 0
122125
graph = Graph(directed=False)
123126
edges = []
124127
for i in range(length):
125-
for j in range(i + offset, length):
128+
for j in range(i + 1, length):
126129
edges.append((i, j))
127130
graph.add_edges(edges)
131+
132+
if loops:
133+
graph.add_loops()
134+
128135
return graph

0 commit comments

Comments
 (0)