in agent/knowledge_graph.py [0:0]
def add(self, connection):
""" Adds a new connection to the graph if it doesn't already exist. """
from_location = connection.from_location
to_location = connection.to_location
gv.event_stream.push(NewConnectionEvent(connection))
if from_location in self._out_graph:
if connection in self._out_graph[from_location]:
return
self._out_graph[from_location].append(connection)
else:
self._out_graph[from_location] = [connection]
if to_location is not None:
if to_location in self._in_graph:
self._in_graph[to_location].append(connection)
else:
self._in_graph[to_location] = [connection]