Skip to content

Commit

Permalink
document and support multigraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor Baart committed Feb 29, 2024
1 parent 59afd68 commit 37add56
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions opentnsim/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ class VesselProperties:
- renewable_fuel_required_space: renewable fuel required storage space (consider packaging factor) on board [m3]
"""

# TODO: add blockage factor S to vessel properties

def __init__(
self,
type,
Expand Down Expand Up @@ -319,14 +317,27 @@ def __init__(self, route, complete_path=None, *args, **kwargs):

@property
def graph(self):
# TODO: explicitly return a digraph or graph but not a multigraph
"""
Return the graph of the underlying environment.
If it's multigraph cast to corresponding type
If you want the multidigraph use the HasMultiGraph mixin
"""
graph is None
if hasattr(self.env, "graph"):
return self.env.graph
graph = self.env.graph
elif hasattr(self.env, "FG"):
return self.env.FG
graph = self.env.FG
else:
raise ValueError("Routable expects .graph to be present on env")

if isinstance(graph, nx.MultiDiGraph):
return nx.DiGraph(graph)
elif isinstance(graph, nx.MultiGraph):
return nx.Graph(graph)
return graph


@deprecated.deprecated(reason="Use Routable instead of Routeable")
class Routeable(Routable):
Expand Down

0 comments on commit 37add56

Please sign in to comment.