Hi evryone,(adsbygoogle = window.adsbygoogle || []).push({});

i have started to write an "algorithm" that finds the Family of a given element in a table of 3 columns:Id,SourceandDestination. When i say Family i mean each element (i.e. A) fromSourcethat has a relation with another one inDestinationand i have to find a family for that new (element) one (coming from A) and so on till there is no sucessor more. May be it would be clear with what i have done so far? please don't be rude :) Thanks (Approach below)

i=0 J value (sucessor) of A :Code (Text):

Array Source(), Destination(), BigArray() int

Variable i, j, k, N, found, pieceToFind int

Variable notFound boolean

//verify if pieceToFind exists in Source()

for i=0;i->N;i++

if pieceToFind != Source(j)

notFound <- true

else found <- pieceToFind

//looking for A sucessors or predecessors

for i=0; i->N; i++

for j=0; j->N; j++

for k=0; k->N; k++

//here i want to bind A with the element located in Destination at the same NodeId index (i=0, A has value J) and store it in a new Array X() and so on

while (found ... )

.

.

.

A->J

i=7 A -||- F :F->A

i=8 E -||- A :A->E

A->J F->A A->E store in BigArray()

//searching for the new Family of each tied value of A (J, F, E)

case1//ifJexists in Source() and J = Source(j) <- A ignore

//ifJfound in Source() find sucessors

i=0 ignore

case2//ifFexists in Source() and F = Source(j) <- A ignore

//ifFfound in Source() find sucessors

i=6 F value (sucessor) of Z : Z->F, Z->F store in BigArray()i=7 ignore

//searching for the new Family of each tied value of F (Z)

case2.1// ifZexists in Source() and Z = Source(j) <- A ignore

//ifZfound in Source() find sucessors

i=6 ignore

case3//ifEexists in Source() andE= Source(j) <- A ignore

//ifEfound in Source() find sucessors

i=1 E value (sucessor) of B :B->E

i=2 Y -||- E :E->Y

i=3 Z -||- E :E->Z

i=8 ignore

B->E E->Y E->Z store in BigArray()

//searching for the new Family of each tied value ofE(B,Y,Z)

case3.1// ifBexists in Source() and B = Source(j) <- A ignore

//ifBfound in Source() find sucessors

i=1 ignore

i=4 B value(sucessor) of X : X->B,X->B store in BigArray()

case3.2// ifYexists in Source() and Y = Source(j) <- A ignore

//ifYfound in Source() find sucessors

i=2 ignore

case3.3// ifZexists in Source() and Z = Source(j) <- A ignore

//ifZfound in Source() find sucessors

i= 3 ignore

i=6 F value(sucessor) of Z: Z->F,Z->F store in BigArray()

//Looking now for duplication

BigArray=(A->J, F->A, A->E, Z->F, B->E, E->Y, E->Z, X->B, Z->F)

//if duplication exists, erase both

BigArray=(A->J, F->A, A->E, B->E, E->Y, E->Z, X->B)

BigArray is the result i want to have at the end.

I can understand that some of you might not get what i have done so far but it was the best way for me to explain it like this. Thank you

(sorry english is not my first language :) )

Best Regards

Charly

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Search the family of an element in a table

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads for Search family element |
---|

Python Removing a list element that repeats itself -- Solved |

Ron eats Hermione's family: Computer writes Harry Potter |

Reading matrix elements from a file in Fortran77 |

**Physics Forums | Science Articles, Homework Help, Discussion**