tEdgeFromPosition ::
  (Ord (e a), Ord a, Show (e a), Show a, Graph.Edge e) =>
  Idx.State ->
  TopoIdx.Position a ->
  State.Graph a e sectionLabel nl storageLabel el carryLabel ->
  Maybe (e a)
getEdgeFromPosition state (TopoIdx.Position f t) =
  let g flowTopo =
        case Set.toList es of
             [e] -> e
             _ -> error $ "More or less than exactly one edge between nodes "
                          ++ show f ++ " and " ++ show t ++ " in " ++ show es
        where es = Graph.adjacentEdges flowTopo f
                     `Set.intersection` Graph.adjacentEdges flowTopo t
  in fmap g . ModUt.getFlowTopology state


getEdgeFromPosition ::
  (Ord (e a), Ord a, Show (e a), Show a, Graph.Edge e) =>
  Idx.State ->
  TopoIdx.Position a ->
  State.Graph a e sectionLabel nl storageLabel el carryLabel ->
  Maybe (e a)
getEdgeFromPosition state (TopoIdx.Position f t) =
  let g flowTopo =
        case Set.toList es of
             [e] -> e
             _ -> error $ "More or less than exactly one edge between nodes "
                          ++ show f ++ " and " ++ show t ++ " in " ++ show es
        where es = Graph.adjacentEdges flowTopo f
                     `Set.intersection` Graph.adjacentEdges flowTopo t
  in fmap g . ModUt.getFlowTopology state
getEdgeFromPosition state (TopoIdx.Position f t) =
  let g flowTopo =
        case Set.toList es of
             [e] -> e
             _ -> error $ "More or less than exactly one edge between nodes "
                          ++ show f ++ " and " ++ show t ++ " in " ++ show es
        where es = Graph.adjacentEdges flowTopo f
                     `Set.intersection` Graph.adjacentEdges flowTopo t
  in fmap g . ModUt.getFlowTopology state