Skip to content

Commit

Permalink
networks.Chain: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmorgan committed Jun 15, 2015
1 parent 697f359 commit b570e77
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wallace/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ def add_agent(self, newcomer):
agents = self.nodes(type=Agent)
other_agents = [a for a in agents if a.uuid != newcomer.uuid]

if len(agents) > 1:
from operator import attrgetter
sources = self.nodes(type=Source)

from operator import attrgetter
if other_agents:
max(other_agents, key=attrgetter('creation_time')).connect(whom=newcomer)
elif len(self.nodes(type=Source)) > 0:
self.nodes(type=Source)[0].connect(whom=newcomer)
elif sources:
min(sources, key=attrgetter('creation_time')).connect(whom=newcomer)

def add_source(self, source):
if len(self.nodes(type=Source)) > 1:
Expand Down

0 comments on commit b570e77

Please sign in to comment.