class_docstr: Layer is where Sugiyama layout organises vertices in hierarchical lists.
  The placement of a vertex is done by the Sugiyama class, but it highly relies on
  the *ordering* of vertices in each layer to reduce crossings.
  This ordering depends on the neighbors found in the upper or lower layers.
  
  Attributes:
      layout (SugiyamaLayout): a reference to the sugiyama layout instance that contains this layer
      upper (Layer): a reference to the *upper* layer (layer-1)
      lower (Layer): a reference to the *lower* layer (layer+1)
      crossings (int) : number of crossings detected in this layer
  
  Methods:
      setup (layout): set initial attributes values from provided layout
      nextlayer(): returns *next* layer in the current layout's direction parameter.
      prevlayer(): returns *previous* layer in the current layout's direction parameter.
      order(): compute *optimal* ordering of vertices within the layer.
class_docstr_tok: ["Layer","is","where","Sugiyama","layout","organises","vertices","in","hierarchical","lists",".","The","placement","of","a","vertex","is","done","by","the","Sugiyama","class",",","but","it","highly","relies","on","the","*","ordering","*","of","vertices","in","each","layer","to","reduce","crossings",".","This","ordering","depends","on","the","neighbors","found","in","the","upper","or","lower","layers",".","Attributes",":","layout","(","SugiyamaLayout",")",":","a","reference","to","the","sugiyama","layout","instance","that","contains","this","layer","upper","(","Layer",")",":","a","reference","to","the","*","upper","*","layer","(","layer-1",")","lower","(","Layer",")",":","a","reference","to","the","*","lower","*","layer","(","layer+1",")","crossings","(","int",")",":","number","of","crossings","detected","in","this","layer","Methods",":","setup","(","layout",")",":","set","initial","attributes","values","from","provided","layout","nextlayer","(",")",":","returns","*","next","*","layer","in","the","current","layout","'s","direction","parameter",".","prevlayer","(",")",":","returns","*","previous","*","layer","in","the","current","layout","'s","direction","parameter",".","order","(",")",":","compute","*","optimal","*","ordering","of","vertices","within","the","layer","."]
docstr: neighbors refer to upper/lower adjacent nodes.
  Note that v.neighbors() provides neighbors of v in the graph, while
  this method provides the Vertex and DummyVertex adjacent to v in the
  upper or lower layer (depending on layout.dirv state).
docstr_tok: ["neighbors","refer","to","upper\/lower","adjacent","nodes",".","Note","that","v.neighbors","(",")","provides","neighbors","of","v","in","the","graph",",","while","this","method","provides","the","Vertex","and","DummyVertex","adjacent","to","v","in","the","upper","or","lower","layer","(","depending","on","layout.dirv","state",")","."]
code: def neighbors(self, v):
      """
      neighbors refer to upper/lower adjacent nodes.
      Note that v.neighbors() provides neighbors of v in the graph, while
      this method provides the Vertex and DummyVertex adjacent to v in the
      upper or lower layer (depending on layout.dirv state).
      """
      assert self.layout.dag
      direction = self.layout.dirv
      layout_vertex = self.layout.layoutVertices[v]
      layer_index = layout_vertex.layer
      if (
          layout_vertex.nvs is not None
          and direction in layout_vertex.nvs
      ):
          return layout_vertex.nvs[direction]
      else:
          above = [
              u
              for u in v.neighbors(0)
              if self.layout.layoutVertices[u].layer == layer_index - 1
          ]
          below = [
              u
              for u in v.neighbors(0)
              if self.layout.layoutVertices[u].layer == layer_index + 1
          ]
          layout_vertex.nvs = {-1: above, +1: below}
          # if layout_vertex.dummy:
          return layout_vertex.nvs[direction]
  
file_path: pygraphistry/graphistry/layout/utils/layer.py
imports: from bisect import bisect
label_desc: Use image node_id 9 for calling the Layer obj's underlying member method code with example usage: obj.neighbors(v) and returns: layout_vertex, layout_vertex