Recent

Author Topic: How to show product routing from database to program?  (Read 1687 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 1591
Re: How to show product routing from database to program?
« Reply #15 on: October 07, 2022, 01:45:27 pm »
What fails me is that there is no way, in the .csv file data supplied, to determine that the graphic steps in 29 to 30 can be permuted. Each  has only one et_modeop_pere so it is not possible to know if an et_modeop can go to an alternative et_modeop thru the et_modeop_pere relation.

Saying an et_modeop can go to an alternative et_modeop means you have to build a down line from et_modeop_pere to its et_modeop. That would be best done with specialised class being fed from the source data by et_nomen identity (product nr ?).
Bruno, that's why i said, his mistake is "looking back".
Look at my approach (looking forward)
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

alpine

  • Hero Member
  • *****
  • Posts: 625
Re: How to show product routing from database to program?
« Reply #16 on: October 07, 2022, 02:21:17 pm »
Before engaging with such a problem the OP must give more information about it. The two columns define a graph, presumably directed, but no more info is available.
Can there be loops? Obviously the start node is the first one. Are there terminal nodes? Are there other restrictions?

The trivial solutions:
Put nodes around a circle, connect them with a straight connectors, or
Put nodes in a line, connect them with arc connectors with a height proportional to the relative distance between nodes.

Other layouts will require things like topological sort of the nodes. A bit of graph theory will help here.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Jonvy

  • Jr. Member
  • **
  • Posts: 70
Re: How to show product routing from database to program?
« Reply #17 on: October 08, 2022, 08:17:04 am »
Before engaging with such a problem the OP must give more information about it. The two columns define a graph, presumably directed, but no more info is available.
Can there be loops? Obviously the start node is the first one. Are there terminal nodes? Are there other restrictions?

There is no loops, only one directly,from beginning to the end.
For the terminal nodes, should judge from data, if one value only appears in column et_modeop, not in et_modeop_pere, then this node is terminal nodes.
No other restrictions.

Jonvy

  • Jr. Member
  • **
  • Posts: 70
Re: How to show product routing from database to program?
« Reply #18 on: October 08, 2022, 08:55:33 am »

Bruno, that's why i said, his mistake is "looking back".
Look at my approach (looking forward)

Hello Zvoni,
Actually for this process routing graph, I should look both backwards and forward.
For the 1st point, I must find in column et_modeop_pere the value is null, so node 8251 in et_modeop is the 1st point(1st product process).
Then I'll check 8251 in column et_modeop_pere, to find the corresponding node 8253 in et_modeop, then 8253 is the 2nd point(2nd product process).

Follow this idea, next step to check 8253 in et_modeop_pere, find 8255 in et_modeop,8255 is the 3rd point.

In this way,can find 1st and 30th point(means product manufactured after 30 steps, it turns from component become final product), still 6 values not used in the data.
These are next branch after node 8685. Check 2nd 8685 in et_modeop_pere, find  corresponding node in et_modeop, can finish the next branch.

But still the drawing after node 8685 is a little difficult.





alpine

  • Hero Member
  • *****
  • Posts: 625
Re: How to show product routing from database to program?
« Reply #19 on: October 08, 2022, 11:49:04 am »
Before engaging with such a problem the OP must give more information about it. The two columns define a graph, presumably directed, but no more info is available.
Can there be loops? Obviously the start node is the first one. Are there terminal nodes? Are there other restrictions?

There is no loops, only one directly,from beginning to the end.
For the terminal nodes, should judge from data, if one value only appears in column et_modeop, not in et_modeop_pere, then this node is terminal nodes.
No other restrictions.

Right, it is acyclic graph then. You should perform topological sort on the nodes first and then it will be easy to make the layout
https://rosettacode.org/wiki/Topological_sort#Object_Pascal
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

avk

  • Hero Member
  • *****
  • Posts: 682
Re: How to show product routing from database to program?
« Reply #20 on: October 09, 2022, 07:24:03 pm »
Sorry for off topic,
...
Right, it is acyclic graph then. You should perform topological sort on the nodes first and then it will be easy to make the layout
https://rosettacode.org/wiki/Topological_sort#Object_Pascal

I was surprised to find that the mentioned solution contains over 400(!) lines of code. Isn't that too much for this task?

BrunoK

  • Sr. Member
  • ****
  • Posts: 368
  • Retired programmer
Re: How to show product routing from database to program?
« Reply #21 on: October 09, 2022, 09:45:34 pm »
I played a bit with your supplied data.
Attached is a project that takes your .csv file and builds a tree corresponding to the structure of your graph with pere->child and child->pere bindings.
Beginning of hierarchy for the nomen lines have -1 in et_modeop_pere node field.
Bottom line terminator have child_steps.count = 0.
Following the child_steps you have the chain from pere to child(ren) and following the pere_steps list items you walk from child node to pere node(s).

alpine

  • Hero Member
  • *****
  • Posts: 625
Re: How to show product routing from database to program?
« Reply #22 on: October 10, 2022, 11:08:54 am »
Apologies for the over-complicated sort example in my previous post.
Here is a new one I wrote, the idea is to approximate the left-right layout seen in the previous posts attachments.

The output of the program should be something like:
Code: Text  [Select][+][-]
  1. 8251(1,1) 8253(2,1) 8255(3,1) 8257(4,1) 8277(5,1) 8435(6,1) 8437(7,1) 8439(8,1) 8447(9,1) 8445(10,1) 8451(11,1) 8453(12,1) 8455(13,1) 8457(14,1) 8463(15,1) 8465(16,1) 8467(17,1) 8469(18,1) 8475(19,1) 8473(20,1) 8487(21,1) 8683(22,1) 8491(23,1) 8685(24,1) 8499(25,1) 8505(26,1) 8507(27,1) 8865(28,1) 8555(25,2) 8561(26,2) 8563(27,2) 8869(28,2) 8525(29,1) 8579(29,2) 8531(30,1) 8585(30,2)

The steps are followed by their (X,Y) relative offset. Y offsets are bound from 1 up. To achieve the "Y-centered" layout it will require an additional pass when the maximal of Y is known.

EDIT: Of course, this is only a example how the layout can be approximated, the final program should combine the contents of Sorted, XOffsets, YOffsets (and probably more) arrays into one array/container with a single encapsulated object for each node.

« Last Edit: October 10, 2022, 11:21:14 am by y.ivanov »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

avk

  • Hero Member
  • *****
  • Posts: 682
Re: How to show product routing from database to program?
« Reply #23 on: October 11, 2022, 10:44:29 am »
Apologies for the over-complicated sort example in my previous post.
...

Added to the page Rosetta Code: Topological sorting another example(seems simpler and more understandable) in the Pascal section.

 

TinyPortal © 2005-2018