Ejemplo n.º 1
0
 def obj_get_list(self, bundle, **kwargs):
   lz = LazyGraph()
   nd = lz.get_node_dict()
   edges = [edge for edge in Edge.objects.all()]
   for edge in edges:
     edge.node_src = nd[edge.node_src_id]
     edge.node_sink = nd[edge.node_sink_id]
   
   return edges
Ejemplo n.º 2
0
  def obj_get_list(self, bundle, **kwargs):
    from_id = int(bundle.request.GET.get('from_id', -1))
    to_id = int(bundle.request.GET.get('to_id', -1))

    if from_id != -1 and to_id != -1:
      from_building = Building.objects.get(id=from_id)
      to_building = Building.objects.get(id=to_id)

      node_from_id = Node.objects.filter(building=from_building)[0].id
      node_to_id = Node.objects.filter(building=to_building)[0].id

      lz = LazyGraph()
      nd = lz.get_node_dict()
      length, path = nx.bidirectional_dijkstra(lz.get_graph(), from_id, to_id, weight='weight')

      return [nd[x] for x in path]

    return []
Ejemplo n.º 3
0
 def obj_get_list(self, bundle, **kwargs):
   lz = LazyGraph()
   return lz.get_node_dict().values()