Exemple #1
0
        public long[] Solve(long NodeCount, long EdgeCount,
                            long[][] edges, long QueriesCount,
                            long[][] Queries)
        {
            Dictionary <long[], long> resDict = new Dictionary <long[], long>();

            long[]        result = new long[QueriesCount];
            WeightedGraph g      = new WeightedGraph(NodeCount, edges, true);

            for (int i = 0; i < QueriesCount; i++)
            {
                if (resDict.ContainsKey(Queries[i]))
                {
                    result[i] = resDict[Queries[i]];
                }
                else
                {
                    resDict[Queries[i]] = g.BiDijkstra((int)Queries[i][0], (int)Queries[i][1]);
                    result[i]           = resDict[Queries[i]];
                }
            }
            return(result);
        }
Exemple #2
0
        public long Solve(long nodeCount, long [][] edges, long startNode, long endNode)
        {
            WeightedGraph g = new WeightedGraph(nodeCount, edges);

            return(g.ShortestPath((int)startNode, (int)endNode));
        }
Exemple #3
0
        public long Solve(long nodeCount, long[][] edges)
        {
            WeightedGraph g = new WeightedGraph(nodeCount, edges);

            return(g.NegativeCycleDetection() ? 1 : 0);
        }
Exemple #4
0
        public string[] Solve(long nodeCount, long[][] edges, long startNode)
        {
            WeightedGraph g = new WeightedGraph(nodeCount, edges);

            return(g.Arbitrage((int)startNode));
        }