Python Forum
Node Flow Generation in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Node Flow Generation in Python
#1
Hey all,

I was working on a project (code included). I wanted to simulate the flow of several nodes. Each node can go to several other nodes. This is stored in a dictionary.

Numbers = [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] = Letters = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]

road_key = {A: (B, D), B: (C, E, H), C: (B,D,F), D: (A,C,F,G), E: (B,K,F), F: (C,D,E), G: (D, J, M), H: (B, K, I), I: (H,J,L), J: (I,P,G), K: (E,H,N), L: (I,M,N,O), M:(G,P,L), N:(L,Q,K), O:(L,Q), P: (J,Q,M), Q:(N,O,P)}
letter_list = []
def flow(letter_key):
	letter_list.append(letter_key)
	

flow(A)
I want to start the flow through function flow(), which takes a key. I want to continue flowing down a chain, until the letter_list is full to 17 numbers. Again, I want to generate every possible combination of letters. So, if I were to flow(A), I want to generate a flow of A -> B or D, from B or D, going to (C,E,H) or (B,D,F), and on and on.

I am having trouble figuring out a way to store every individual iteration, as I think that would take a lot of lists/containers for each possible combination.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Alicat Flow Meter data acquisition marenr 0 354 Sep-29-2023, 10:59 PM
Last Post: marenr
  Allure Report Generation rotemz 0 792 Jan-24-2023, 08:30 PM
Last Post: rotemz
  Python Split json into separate json based on node value CzarR 1 5,637 Jul-08-2022, 07:55 PM
Last Post: Larz60+
  Why doesnt chunk generation work? LotosProgramer 1 1,953 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  Flow Control Help RoadToSensei 5 1,701 Feb-14-2022, 08:21 PM
Last Post: deanhystad
  Random data generation sum to 1 by rounding juniorcoder 9 3,455 Oct-20-2021, 03:36 PM
Last Post: deanhystad
Question PDF generation / edit SpongeB0B 2 2,093 Jul-28-2021, 05:59 AM
Last Post: SpongeB0B
  Calling Input for Random Generation ScaledCodingWarrior 1 1,865 Feb-02-2021, 07:27 PM
Last Post: bowlofred
  Understanding Raspberry PI RTS/CTS flow control zazas321 2 3,647 Oct-30-2020, 09:55 AM
Last Post: zazas321
  Understanding Raspberry PI RTS/CTS flow control zazas321 0 1,509 Oct-30-2020, 08:02 AM
Last Post: zazas321

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020