sinalgo icon indicating copy to clipboard operation
sinalgo copied to clipboard

Help wanted about multiple edges

Open HongxuanZhang opened this issue 5 years ago • 15 comments

Hello,it seems that according to the code in the file sinalgo/nodes/NodeOutgoingConnectionsList.java, there cannot be multiple edges between two nodes, but I really need it in my project. Could you give me some advice about how to allow the multiple edges without effect other functions of the framework?

Thanks a lot!

HongxuanZhang avatar Jan 28 '21 03:01 HongxuanZhang

Hi there,

May I ask you what kind of problem you're trying to simulate that requires multiple edges?

andrebrait avatar Jan 28 '21 06:01 andrebrait

Thanks for your reply.

My network consists of many trees, and the network topology may change over time.

For example, in two trees A and B, one node α may be the parent of another node β in the Tree A, but may be the child of β in the Tree B. At some time, the Tree B may have to change, and the node β could not be the parent of α in the Tree B after change. But the link between the node α and β have to remain since the α is still the parent of β in the Tree A.

So, it seems there should be two bidirectional links between the nodes α and β.

HongxuanZhang avatar Jan 28 '21 07:01 HongxuanZhang

Hm, got it. Let me think how this can be done and I'll get back to you.

Does one tree influence the other in ways that running the two simulations separately and then joining the results somehow is not enough? I'd assume so, but I'm asking just in case

andrebrait avatar Jan 28 '21 07:01 andrebrait

I really appreciate your help!

Actually you don't have to think about the things about joining the results part, and in fact there is only one simulation but not two. I am only curious about how to use multiple edges based on your framework sinalgo.

Thanks for your any advice!

HongxuanZhang avatar Jan 28 '21 08:01 HongxuanZhang

Hi there! Have you got any idea?

HongxuanZhang avatar Feb 03 '21 11:02 HongxuanZhang

Yes, I do.

So, what I think I can do is to allow you to have multiple, isolated sets of edges. That way you could have each tree independently and, if situation calls for it, you can check for the connectivity between a given pair of nodes on each set of edges independently too.

Would that cover your use-case?

andrebrait avatar Feb 03 '21 12:02 andrebrait

Thanks, that sounds really great!

May I ask how you implement it and how I can use it in my project?

HongxuanZhang avatar Feb 03 '21 12:02 HongxuanZhang

Well, you'd have to modify Sinalgo's source code for that. The current plan is to make an array of lists of edges on the nodes and a few more changes, but it's more complicated than I can explain here. What are your deadlines on this?

andrebrait avatar Feb 03 '21 20:02 andrebrait

Well, the sooner the better. I have to finish this project in about one week.

Many thanks for your work!Please tell me if I can help you to finish it faster.

HongxuanZhang avatar Feb 04 '21 00:02 HongxuanZhang

Hm, a week is definitely not a timeframe in which I can implement this.

An idea would be to create two sets of nodes. Set A and set B, for example, each containing the same number of nodes on the same coordinates. Then you can have two trees at the same time. Some changes would have to be made to the connectivity model, but I think it could work.

On Thu, Feb 4, 2021, 01:59 HXZhang [email protected] wrote:

Well, the sooner the better. I have to finish this project in about one week.

Many thanks for your work!Please tell me if I can help you to finish it faster.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sinalgo/sinalgo/issues/3#issuecomment-772942810, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLX5OU6T3EWYYJCDFNF2GLS5HWOJANCNFSM4WWMAW7Q .

andrebrait avatar Feb 04 '21 12:02 andrebrait

Hello. I want to ask you whether this idea could make it.

In your code, the Node.java use NodeOutgoingConnectionsList which extends DoublyLinkedList as its Connections, but each entry is allowed only once in the collection according to the method add(Node startNode, Node endNode, boolean valid).

I think whether I can change it to a ConnectionsList which allow duplicate Edge, so when I need to modify one edge, it would still have one copy in the List, which seems could meet my requirements.

HongxuanZhang avatar Feb 04 '21 13:02 HongxuanZhang

I see no reason why you cannot do that, but you'd have to extend it yourself.

One thing to be aware of is the ConnectivityModel you choose to use. You'd have to handle node A being connected to B on a given tree, but not on another, and check how you could add edges in each tree that way. I think that, perhaps, simulating multiple trees by just creating a duplicate of each node on top of each other node and treating them as separate things when it comes to connectivity could be better, but I'm not 100% sure if that would work for you.

I'm very busy lately, and unfortunately I cannot look into the required modifications myself.

André Brait

On Thu, Feb 4, 2021 at 2:11 PM HXZhang [email protected] wrote:

Hello. I want to ask you whether this idea could make it.

In your code, the Node.java use NodeOutgoingConnectionsList which extends DoublyLinkedList as its Connections, but each entry is allowed only once in the collection according to the method add(Node startNode, Node endNode, boolean valid).

I think whether I can change it to a ConnectionsList which allow duplicate Edge, so when I need to modify one edge, it would still have one copy in the List, which seems could meet my requirements.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sinalgo/sinalgo/issues/3#issuecomment-773293113, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLX5OVZVJAJIINSYXVQ74TS5KMI5ANCNFSM4WWMAW7Q .

andrebrait avatar Feb 04 '21 15:02 andrebrait

Last question, should I put the class file which extends Node.java and allow duplicate Edges according to your advice in the folder named nodeImplementations

Many thanks for your help!

HongxuanZhang avatar Feb 05 '21 07:02 HongxuanZhang

Yes, that is correct. The package also has to correspond to it, of course. Look into the examples if you want to know the basic layout for it. Let me know if that's not clear though.

On Fri, Feb 5, 2021, 08:14 HXZhang [email protected] wrote:

Last question, should I put the class file which extends Node.java and allow duplicate Edges according to your advice in the folder named nodeImplementations

Many thanks for your help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sinalgo/sinalgo/issues/3#issuecomment-773843898, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLX5OSLF3KGGGK52G4OQ4LS5OLEPANCNFSM4WWMAW7Q .

andrebrait avatar Feb 05 '21 07:02 andrebrait

That 's clear, Thank you!

HongxuanZhang avatar Feb 05 '21 07:02 HongxuanZhang