# Path: misc/objects.py
# def str_object(obj):
#   if type(obj) in (list, np.ndarray):
#     return '[%s]' % ', '.join(str_object(item) for item in obj)
#   if type(obj) == tuple:
#     return '(%s)' % ', '.join(str_object(item) for item in obj)
#   if type(obj) == dict:
#     return '{%s}' % ', '.join(str_object(item) + ': ' +  str_object(obj[item])
#                               for item in sorted(obj.keys(), key=lambda k: str_object(k)))
#   if type(obj) in (set, frozenset):
#     return '{%s}' % ', '.join(sorted(str_object(item) for item in obj))
#   if type(obj) in (float, np.float64):
#     obj = round(obj, 3)
#     if obj == 0:
#       obj = 0 # NOTE - catches -0.0 bug
#     return '%.3f'%obj
#   if isinstance(obj, types.FunctionType):
#     return obj.__name__
#   return str(obj)
# 
# Path: misc/functions.py
# def flatten(iterable_of_iterables):
#   return (item for iterables in iterable_of_iterables for item in iterables)


from .utils import *
from misc.objects import str_object
from misc.functions import flatten

class Vertex(object):
  def __init__(self, substate, rg):
    self.substate = substate
    self.rg = rg
    #self.sources = set() # (source_vertex, edge): edge(source) = self
    #self.sinks = set() # (sink_vertex, edge): edge(self) = sink_vertex
    #self.connectors = set()
    self.sources = [] # (source_vertex, edge): edge(source) = self
    self.sinks = [] # (sink_vertex, edge): edge(self) = sink_vertex
    self.connectors = [] # The sets are causing issues
    self.reset()

  def reset(self):
    self.reachable = False
    self.active = False
    self.activations = 0
    self.initial = False
    self.active_dirty_bit = 0

  def incoming(self):

# Path: misc/objects.py
# def str_object(obj):
#   if type(obj) in (list, np.ndarray):
#     return '[%s]' % ', '.join(str_object(item) for item in obj)
#   if type(obj) == tuple:
#     return '(%s)' % ', '.join(str_object(item) for item in obj)
#   if type(obj) == dict:
#     return '{%s}' % ', '.join(str_object(item) + ': ' +  str_object(obj[item])
#                               for item in sorted(obj.keys(), key=lambda k: str_object(k)))
#   if type(obj) in (set, frozenset):
#     return '{%s}' % ', '.join(sorted(str_object(item) for item in obj))
#   if type(obj) in (float, np.float64):
#     obj = round(obj, 3)
#     if obj == 0:
#       obj = 0 # NOTE - catches -0.0 bug
#     return '%.3f'%obj
#   if isinstance(obj, types.FunctionType):
#     return obj.__name__
#   return str(obj)
# 
# Path: misc/functions.py
# def flatten(iterable_of_iterables):
#   return (item for iterables in iterable_of_iterables for item in iterables)


# Path: retired/planners/connectivity_graph/vertex.py
from .utils import *
from misc.objects import str_object
from misc.functions import flatten


class Vertex(object):
  def __init__(self, substate, rg):
    self.substate = substate
    self.rg = rg
    #self.sources = set() # (source_vertex, edge): edge(source) = self
    #self.sinks = set() # (sink_vertex, edge): edge(self) = sink_vertex
    #self.connectors = set()
    self.sources = [] # (source_vertex, edge): edge(source) = self
    self.sinks = [] # (sink_vertex, edge): edge(self) = sink_vertex
    self.connectors = [] # The sets are causing issues
    self.reset()

  def reset(self):
    self.reachable = False
    self.active = False
    self.activations = 0
    self.initial = False
    self.active_dirty_bit = 0

  def incoming(self):

    return [edge for _, edge in self.sinks] #+ [edge for source_vertex, _ in self.sinks]