cauldron / activity-browser

GUI for Brightway
GNU Lesser General Public License v3.0
0 stars 2 forks source link

Add tree-based contribution analysis #30

Open cmutel opened 6 days ago

cmutel commented 6 days ago

Feature request

One can currently see the impact of different processes in the supply chain via a bar chart:

Screenshot 2024-06-27 at 22 18 51

And via a Sankey graph:

Screenshot 2024-06-27 at 22 25 15

Our client would like to have a more interactive contribution analysis based on an expanding tree. This would follow the standard "clickable triangle" pattern where clicking on the triangle expands impacts. The basic interface would look something like this:

Reference flow: [dropdown]
Impact indicator: [dropdown]
Tag system: [dropdown]

┐ Reference flow
├─ Input A
├─ Input B
└─ Input C

Where Input A, etc., could be clicked to expand or contract.

To calculate the initial set of impacts, run graph traversal in the same way as the Sankey example. This graph traversal object should be kept in memory, so that further calculations can be done quickly. The initial calculation should use a shallow max_depth, either 1 or 2, and subsequent calculations (upon clicks) should do the same thing, but starting from the clicked node as the new functional unit.

If a tag system is chosen, then inputs should be grouped, so one would instead see something like:

┐ Reference flow
├─ Tag A
├─ Tag B
└─ Input C

Specific tasks:

Screenshot 2024-06-27 at 23 23 44
marc-vdm commented 5 days ago

Hi Chris,

I built something somewhat similar to this ~year back, see this PR, which may be some useful reference for you https://github.com/LCA-ActivityBrowser/activity-browser/pull/1046

I also used graph traversal to calculate these impacts. Happy to have a quick chat if it helps.

I do have some vague ideas for a more generalized graph traversal as well, that could be interesting to implement in BW at some point.

cmutel commented 5 days ago

Thanks @marc-vdm. We will check this out, and of course would be happy to get your feedback once we have an alpha.