Shortest path in the Bidirectional Weighted Graph - math

Each node is connected to the other.
Connection from Node1 to Node2 is not the same in the cost as connection from Node2 to Node1.
Given the graph connection Weight.
Is there any effective algorithm to calculate the fastest(lowest cost) path of two nodes?
What's the name of this type of Graph in Math?

Is there any effective algorithm to calculate the fastest(lowest cost)
path of two nodes?
Dijkstra
What's the name of this type of Graph in Math?
Directed
Connection from Node1 to Node2 is not the same in the cost as
connection from Node2 to Node1.
To handle this, you can construct a directed graph with two edges between every connected pair of vertices, costed according to the direction of travel.

Related

On what depends calculation of vertex positions in a network by default?

I have a directed network consisting of 80 vertices and 500 edges. How are vertex positions calculated by default?
I know that it depends on degree and to which vertices a vertex is connected. But what would be a good answer in an exam like situation?

Find subgraphs that can only be reached by two nodes

I want to find subgraphs in a graph that are only connected to the rest of the graph by two nodes; for example, node A is connected to the rest of the graph, as well as node F, but nodes B-E are only connected to each other and A and F (don't have to be fully connected).
Is there a name for this? And is there an algorithm for finding such subgraphs?
The distance of A and F is defined by their shortest path: for example, if d=4, I would want to find all subgraphs where the shortest path between A-like and F-like nodes is at most 4.

Find longest path in graph where each node has at most two incoming and two outgoing edges

As the title says I have to find longest path in directed graph where each node has at most two incoming edges and two outgoing edges. I don't know if that fact helps anything.. The graph will have at most 10000 nodes. And I need to find the longest path from node 0 to node 'Exit' which will be 10001.
I tried to code dijkstra but it didn't work.
Thanks in advance.
You could preprocess your graph and set edge weights to very high values for edges that are connected to nodes that break your rules and then use a modified version of dijkstra that returns longest path.

What characteristics does a directed graph must have so that it is also a valid tree?

I am not asking an algorithm, I am asking definitions.
There is this question: given a graph to detect if it is a tree or not in directed and undirected graphs? According to the selected answer, I came up with the following:
For a directed graph to be a valid tree, it must satisfy all the facts:
The graph must have only 1 vertex that has purely outgoing edges.
The graph is connected.
The undirected version of this graph has no cycles.
I searched online for this and seems like most people agree with these points.
However I am still confused. For example, are the following graphs valid trees?:
G1:
G2:
If yes, why? If no, why?
Any help is appreciated! Thanks!
In case Directed graph, we start from vertex which has outgoing edge. When we have done traversal and is there any unvisited vertex then it is not tree.
For graph G1,
We can start from A, B or C.
If we start from A, then there is no chance to visit B. A->C, C->D or C->E.
If we start from B, then there is no chance to visit A. B->C, C->D or C->E.
And same for C, no chance to visit A and B.
It means there is no way to visit each vertex, so it's not a tree - graph is not connected.
For graph G2,
We can start from A or B.
If we start from A, then there is no chance to visit B and D.
Same case for B.
Therefore, this graph is also not connected.

Determine if undirected graph is connected

I came across this posting from a while back:
Best algorithm to determine if an undirected graph is a tree
It says that to determine if an undirected graph is a tree, you just have to check if it has a cycle. However, don't you have to make sure the graph is connected? I was taught that a tree is connected and acyclic. How is checking only for acyclicity sufficient?
Thanks.
You're right. If the graph is acyclic, then it's a forest. In addition, if it only has one component, then it's a tree.
What the algorithm mentioned does is look for back edges. If it finds one, then the graph is not a tree. If it doesn't find one and the algorithm visited n-1 edges before running out of edges, then it IS a tree, because having visited n-1 edges means that the graph is indeed connected (a tree with n vertices has n-1 edges). If the algorithm ran out of edges but didn't reach n-1 visited edges, then it means the graph is not connected, hence it is not a tree.

Resources