Skip to content

Suggestion: support for MultiDiGraph #10

@AntonioRochaAZ

Description

@AntonioRochaAZ

Hello, I have a suggestion. Currently, networkx.DiGraph is used for the graph representation of flowsheets. Although adequate for probably all real flowsheets, if the standard is to be used for machine learning applications, there may be loss of information in some edge cases.

For example: "(raw)(col){bout}%1[{tout}(mix)<1(prod)]" represents a flowsheet composed of a column, both exits of which are connected to the same mixer. The DiGraph class does not allow two different edges between the same two nodes, so one of them will be deleted:

f = Flowsheet(sfiles_in="(raw)(col){bout}%1[{tout}(mix)<1(prod)]")
print(f.state.edges()) # Gives: OutEdgeView([('raw-1', 'col-1'), ('col-1', 'mix-1'), ('mix-1', 'prod-1')])
f.convert_to_sfiles()
print(f.sfiles)              # Gives: '(raw)(col){bout}(mix)(prod)'

Of course this process is not relevant in practice, but if a machine learning model is used for generating processes, which are then converted into graphs for simulation, this loss of information may sometimes become an issue during runtime.

I believe that by simply changing the references to networkx.DiGraph to networkx.MultiDiGraph solves this problem. (it may be good to analyse if this doesn't break other parts of the code/introduces edge cases of course).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions