in Education by
I'm writting a graph algorithm and I'm almost there... My algorithm stores several edge objects in a collection of edges, representing a path from initial vertex to final vertex. Thus, there should be also several paths between those vertexes (several collections of edge type), stored in another collection (in my class, callded "collswap"). Each edge is an object which have two vertexes: initial (v) and final (w), in this way: dim manhattan as new vertex dim brooklyn as new vertex dim statenIsland as new vertex dim brooklynBridge as new edge(brooklyn, manhattan) dim route278 as new edge(statenIsland, brooklyn) 'calculates the path and stores the collections in a private property 'collswap' me.returnPath(statenIsland, manhattan) 'in me.collswap (type collection) I have one collection (type 'system.collections.generic.list(of edge)) with two edges (route278 and brooklynBridge) The graph is correctly calculated, but now I have to pick the best path. So, I need to query collswap in ways of: Retrieving only those paths which last edge contains the desired vertex in vertexW property ex: brooklynBridge.vertexW 'retrieves manhattan vertex (because my code can store a path which don't reaches the final vertex) Selecting the minor path between various located (the fewer ellements collection) Would you help-me to build a good (and ellegant) Linq query to carry out these tasks? Thank you! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In C#, sorry. I'm assuming collswap has a collection named paths, each of which is a List of edge. Retrieving only those paths which last edge contains the desired vertex in vertexW property ex: brooklynBridge.vertexW 'retrieves manhattan vertex (because my code can store a path which don't reaches the final vertex) List> goodPaths = collswap.paths.Where(path => path.Last() == manhattan); This gives those paths that end at manhattan. Selecting the minor path between various located (the fewer ellements collection) List shortestGoodPath = goodPaths.OrderBy(path => path.Count()).First(); This gives the first good path, when the good paths are ordered by edge count; that is, this is the shortest good path. You can combine the two operations if you want: List shortestGoodPath = collswap.paths .Where(path => path.Last() == manhattan) .OrderBy(path => path.Count()) .First();

Related questions

0 votes
    I am trying to add some items to a TreeView Control: TV1.Nodes.Add("key1", "Test1") 'Works TV1. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I am trying to nail down free space on a remote server by querying all the drives and then looping ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I'm trying to add data into my Access database in Visual Basic, but I encount this error when I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I'm trying to generate an 837P EDI file using EDIDev. I was able to generate 4 other 837P files ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I was wondering if there is a way to compress my code using a loop, this is my code : ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I was wondering if there is a way to compress my code using a loop, this is my code : ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I'm working on this project and I required to allow the user to select a color from the color ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I know that this should be easy but how do I export/save a DataGridView to excel? JavaScript questions ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I'm working on a form that has a few data grid views that are populated from LINQ queries, no ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    My If Else statement in VB.net is randomly displaying either of the If or ElseIf condition that I made ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    My If Else statement in VB.net is randomly displaying either of the If or ElseIf condition that I made ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am writing down a simple schedule planner app using WinForms in Visual Basic .NET, and I have this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    In VB.NET is there a library of template dialogs I can use? It's easy to create a custom dialog ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 30, 2022 in Education by JackTerrance
0 votes
    In VB.NET is there a library of template dialogs I can use? It's easy to create a custom dialog ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 30, 2022 in Education by JackTerrance
0 votes
    In VB.NET is there a library of template dialogs I can use? It's easy to create a custom dialog ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
...