## Can you use a Martial Discipline Stance from Path of War during underwater combat?

Can you use a Martial Discipline Stance from Path of War during underwater combat?

Specifically Thrashing Dragon Stance: Outer Sphere Stance – When wielding two weapons, disciple inflicts an additional 1d6 points of damage per attack, -2 to AC.

## Using floyd warshel to find the shortest path between two places

To resolve the following question I used travelling salesman algorithm and got results but I’m not sure if that is the correct way. Can someone please help with the below

Butale are really weird country. Even more strange are the mayors and their decisions. The latter is particularly interesting, namely the mayor Francot Turkavidel passed a decree that all roads in Butale must be one Butale mile long. Peter Puzzle immediately felt a business opportunity and came to offer an online service that calculates the shortest path between two places in Butale. Let n be the number of places in Butale and let m be the number of roads.

A) (i.) Describe a data structure that Peter should use for efficient implementation of his service.

(ii.) Write an algorithm that calculates the distance between the places a and b.

B) Peter decided to compute the shortest paths once and for all among all the pairs of places in Butale.

(i.) Write down the Floyd-Warshal algorithm for finding the shortest paths between two arbitrary places but in such a way that it will be possible to reconstruct the path.

(ii.) Can Peter compute it faster than using the Floyd-Warshal’s algorithm? Justify the answer.

C) New mayor and new decisions. Francot’s son Gregor Brezhlaˇcnice slightly modified his father’s decree by allowing that the roads can now be one or two Butale miles long.

(i.) What shall Peter do so that he could still use the solution from A? Justify the answer.

(ii.) How does the time complexity of the solution change? Justify the answer.

## Find shortest path in a graph with a array of queues

Recently, I saw a video by a Errichto about solving leetcode move boxes problem. This problem is essentially a graph problem where each vertex describing the state of the system and might be described by 4 integer values (coordinates of the box and the player). Each edge has weight 1 or 0. The author used an interesting approach with many queues (more specifically he used vector instead of queue but this is an implementation detail). There is one queue for each possible distance from the source. Interestingly, he says that this is a generalization of the know dequeue technique to solve shortest path in 0/1 edge weighted graph.

I wonder if there is a formal analysis of this approach to understand when it is rational to apply instead of Dijkstra. Could not find anything so far.

## Linear space reduction from Directed Hamiltonian Path Problem to 3SAT

Is there a reduction from Directed Hamiltonian Path Problem to 3SAT which is linear in the number of vertices? That is, it reduces every graph $$G$$ with $$n$$ vertices to a formula $$\varphi$$ with at most $$O(n)$$ clauses?

Since Cook Levin Theorem shows a reduction that proves 3SAT is NPC, almost all of the literature deals only with reductions from 3SAT, and only rarely one can find in the literature reductions to 3SAT.

After searching the web I found this and other cites that have the other direction of reduction (from 3SAT to dHamPath).

## Determine whether there exists a path in a directed acyclical graph that reaches all nodes without revisiting a node

For this I came up with a DFS recursion.

Do DFS from any node and keep doing it until all nodes are Exhausted. I.E. pick the next unvisited node once you cant keep recursing.

The element with the highest post number or the last element you visit should be the first element in your topological ordering.

Now do another DFS recursion that executes on every node called DFS_find:

DFS_find(Node): if (node has no neighbors): return 1; otherwise: return 1 + the maximum of DFS_find(Node) for all neighboring nodes

Execute DFS_find(Node) on the first node in your topological ordering. If it returns a number equal to the number of vertices, then a directed path that crosses every node once, exists. Otherwise it does not.

How can I prove whether or not this algorithm is correct?

I think this may be a little less time efficient than the classical way to just do a topological sort and then check if each consecutive pair has an edge between them.

## Does the Grave Cleric’s “Path to the Grave” feature override an immunity of a creature?

Let’s say a creature (like a devil) is normally immune to fire damage. The unfortunate devil is within 30ft of a Grave Cleric and their Sorcerer friend.

The Grave Cleric uses their Path to the grave feature:

As an action, you choose one creature you can see within 30ft of you, cursing it until the end of your next turn. The next time you or an ally of yours hits the cursed creature with an attack, the creature has vulnerability to all of that attack’s damage, and then the curse ends.

Is the devil still immune? Or are they instead vulnerable to the damage?

To put it another way, does the Path to the Grave replace the immunity with a vulnerability? Or does it add a vulnerability on top of the immunity?

## Johnson shortest path work for undirected graphs?

Does Johnson’s shortest path algorithm works for Undirected graphs? All examples I am seeing with Johnson algorithm use directed graphs, but nobody is clear about what kind of graph was it designed for? Directed or Un-Directed?

## Comparing shortest path distance and relation between two modes present in FIFO queue at the same time during breadth first traversal

I came across following problem:

Consider two vertices $$a$$ and $$b$$ that are simultaneously on the FIFO queue at same point during the execution of breadth first search from $$s$$ in an undirected graph. Then which of the following is true:

1. The number of edges on the shortest path between $$s$$ and $$a$$ is at most one more than the number of edges on the shortest path between $$s$$ and $$b$$.
2. The number of edges on the shortest path between $$s$$ and $$a$$ is at least one less than the number of edges on the shortest path between $$s$$ and $$b$$.
3. There is a path between $$a$$ and $$b$$.
4. $$a$$ may lie on shortest path from $$s$$ to $$b$$.

The solution just said first three may hold separately. But that really left me confused. Especially it did not say anything about point 4.

Here is what I guess is correct:

1. The shortest path distance of two nodes simultaneously present in FIFO queue can differ at max by 1. That is one node may be closer to source by at max just 1 edge than the other or it may be present at the same distance from source as other node. So either point 1 is correct or point 2, but not both. Am I right with this?

2. Also what is significance of “at most” and “at least” in point 1 and point 2? I feel the difference between shortest path distance if two nodes can be “at most” 1. I guess “at most one more” aligns with this, but “at least one less” does not. That is shortest path distance of node $$a$$ cannot be lesser than that of node $$b$$ by 2 or more.

3. I feel point 3 will always be true as there will always be path from $$a$$ to $$b$$ going through $$s$$

4. I feel point 4 is always false, because we dequeue the node $$a$$ and then enqueue all its neighbours, one of which is $$b$$. So such $$a$$ and $$b$$ cannot be in the queue at the same time.

Am I correct with these?

## Time complexity analysis of shortest path algorithm

Below is Dijkstra’s algorithm from CLRS:

In the time complexity analysis of Dijkstra, CLRS says, RELAX() contains call to DECREASE-KEY(), which is essentially reducing edge weights associated with nodes stored in priority queue implemented as binary min heap.

Now in DAG-SHORTEST-PATHS() algorithm below, it says inner loop takes O(1). But I guess we need to run topological sort at the time of every relax(). So the inner loop wont be $$\Theta(1)$$ and overall complexity will be $$\Theta(E^2)$$ or something else but definitely not $$\Theta(V+E)$$ as stated.

Am I correct with this?

## How Dijkstra’s algorithm forms shortest path tree when multiple nodes have same shortest path length

I came across following problem:

Consider below graph:

What will be the shortest path tree starting with node $$A$$ returned by Dijkstra’s algorithm, if we assume priority queue is implemented as binary min heap?

My solution:

I referred Dijkstra from CLRS:

With A as a starting node, we will have priority queue bin min heap as follows:

A{root, 0}     | Rest all:{∅,∞} 

(Notation: {parent in SPT, shortest path weight})

It will extract A from priority queue and add it to SPT and will relax AC and AB:

    B{A:5}      /  \ C{A:6}  Rest all:{∅,∞}  

It will extract B from priority queue and and add it to SPT:

   C{A:6}       | Rest all:{∅,∞}  

and will relax BE:

            C{A:6}              /   \ Rest all:{∅,∞}   E{B,6} 

Next it will extract C and so one. Thus the SPT will be:

But not:

Q1. Am I correct with above?
Q2. CLRS algo does not dictate which node to add to SPT if multiple of them have same shortest path weight. Hence its dependent on how priority queue is implemented. If no information was given about how priority queue was implemented then we cannot tell how SPT will be formed. Am I right?