## Complexity of “does a directed graph have

I am studying the complexity classes and I am confused what is the complexity of the following problem: "Does a directed graph G has at most 1 Hamiltonian cycle?"

So, from my knowledge and understanding:

1. Existence of Hamiltonian cycle is a NP(C) problem.
2. Existence of exactly $$k$$ ($$k>1$$) Hamiltonian cycles in a graph belongs to PSPACE.
3. The stated problem would be a complement of "Does a directed graph G has at least 2 Hamiltonian cycles?"

However, I still fail to see to which class the mentioned problem belongs. Originally I though it would also belong to PSPACE, but not to any space in PSPACE. However, I have consulted my teacher and she said that, while it belongs to PSPACE, it also belongs to some subset of PSPACE. Which subset that would be? Does it belong to co-NP, and the problem from 3. then belongs to NP? If yes, how to prove it (because for now I’m just guessing it based on my teachers’ hint)? If no, where does it belong?

## Oriented spanning tree of a directed multi-graph with minimum weight

I have problem of finding the minimum spanning tree of a simple graph, but the result is restricted by additional two types of condition:

• There is a known root, which is s in the following example.
• We know directions of some edges if they are chosen. These edges are chosen yet, or the problem becomes a Steiner tree problem.

Note that numbers on edges are their weights. So we will get s -> b -> c -> a if a normal min spanning tree is applied, but the direction of edge ac is wrong. On the other hand, we cannot use Chu–Liu/Edmonds’ algorithm for spanning arborescence of directed graphs, because we don’t know and cannot infer the direction of edge bc.

We can infer some edges’ directions according to the position of the root. For example, in the example, we know s -> b and s -> a.

## Oriented Spanning Tree

In the final section of spanning tree, Wikipedia, oriented spanning tree is mentioned and a paper [levine2011sandpile] is referred. The problem fits the setting. It says:

Given a vertex v on a directed multigraph G, an oriented spanning tree T rooted at v is an acyclic subgraph of G in which every vertex other than v has outdegree 1.

Note that the term "outdegree" is a bit confusing, which I think should be "indegree". But it doesn’t matter, because it just restricts the simple subgraph to be a directed tree with root being source or sink.

For edges (in the original simple graph) whose directions are unknown, we add two directed edges between two vertices with inverse directions. Then we find the oriented spanning tree of this multi-graph. But it is not clear to me how an algorithm can be implemented according to that paper.

• Levine, L. (2011). Sandpile groups and spanning trees of directed line graphs. Journal of Combinatorial Theory, Series A, 118(2), 350-364.
• https://en.wikipedia.org/wiki/Spanning_tree

## Shortest Path in a Directed Acyclic Graph with two types of costs

I am given a directed acyclic graph $$G = (V,E)$$, which can be assumed to be topologically ordered (if needed). Each edge $$e$$ in G has two types of costs – a nominal cost $$w(e)$$ and a spiked cost $$p(e)$$. I am also given two nodes in $$G$$, node $$s$$ and node $$t$$.

The goal is to find a path from $$s$$ to $$t$$ that minimizes the following cost: $$\sum_e w(e) + \max_e \{p(e)\},$$ where the sum and maximum are taken over all edges of the path.

Standard dynamic programming methods show that this problem is solvable in $$O(E^2)$$ time. Is there a more efficient way to solve it? Ideally, an $$O(E\cdot \operatorname{polylog}(E,V))$$ algorithm would be nice.

This is the $$O(E^2)$$ solution I found using dynamic programming, if it’ll help.

First, order all costs $$p(e)$$ in an ascending order. This takes $$O(E\log(E))$$ time.

Second, define the state space consisting of states $$(x,i)$$ where $$x$$ is a node in the graph and $$i\in \{1,2,…,|E|\}$$. It represents "We are in node $$x$$, and the highest edge weight $$p(e)$$ we have seen so far is the $$i$$-th largest".

Let $$V(x,i)$$ be the length of the shortest path (in the classical sense) from $$s$$ to $$x$$, where the highest $$p(e)$$ encountered was the $$i$$-th largest. It’s easy to compute $$V(x,i)$$ given $$V(y,j)$$ for any predecessor $$y$$ of $$x$$ and any $$j \in \{1,…,|E|\}$$ (there are two cases to consider – the edge $$y\to x$$ is has the $$j$$-th largest weight, or it does not).

At every state $$(x,i)$$, this computation finds the minimum of about $$\deg(x)$$ values. Thus the complexity is $$O(E) \cdot \sum_{x\in V} \deg(x) = O(E^2),$$ as each node is associated to $$|E|$$ different states.

## In the dataflow programming paradigm programs are modeled as directed graphs. Are the edges of the graph variables? And are the vertexes functions?

As I understand it in dataflow programming, programs are structured as directed graphs, an example of which is below

Is it true to say that the arrows (or edges) represent the variables within a program and the vertexes (blue circles) represent programmatic functions? Or is this too much of a simplification?

I am interested in understanding how dataflow languages actually apply graph theory.

## Directed Grid Graphs; All Possible Paths Through Nodes

I have a problem in which I am interested in taking a matrix of positive integer weights, including zero, where the matrix has dimensions nrow x ncol and the columns always sum to the same arbitrary number. I want to search for a list of paths (sets of edges essentially) that traverse through the grid space of the same dimension & create the paths such that the # of edges in a path going through a node is equal to the nodes weight (from the matrix). Ie: if a particular index in my matrix was "3", there would be 3 edges that would run into (and out of) this node.

Some important restrictions. Firstly, The only direction the edges can move is rightward (so vertical edges are disallowed) but only one column distance at a time. I do allow for the edges to go from any row_j (in column_i) to any other possible row_j in column_i+1, so diagonal edges (either upwards or downwards are allowed). Here’s an example of such a solution (it is non singular which is why Im interested in ALL possible paths)

Most importantly, I am interested in two things. First I want all possible paths from this process, and even more critically, I want to minimise the number of possible diagonal edges that my resulting paths will contain.

Any sort of algorithm here to solve this would be hugely helpful.

I have managed to solve the case when I don’t care about the number of diagonal edges, and just want a set of paths that match with the weights. To do that, I used the weights at adjacent columns to generate a Markov transition process. This gave me a series of transition matrices (of length ncol-1) which from there I was able to construct probabilistically what my paths through my weights were.

Let me know if anyone needs any more details/explanations here.

## Finding paths of length $n$ on a directed graph

Suppose I have the following directed graph

g = Graph[{DirectedEdge[v1, v1, a], DirectedEdge[v1, v1, OverBar[a]],     DirectedEdge[v1, v2, b], DirectedEdge[v2, v2, c],     DirectedEdge[v1, v3, OverBar[b]],     DirectedEdge[v3, v3, OverBar[c]]}, VertexLabels -> "Name",    EdgeLabels -> "Index"] 

First of all, I would prefer to label the edges with the tag of the directed edge, but I’m not sure how to do this.

The main question is, can Mathematica give me all possible paths of length $$n$$ on this graph starting from, say, $$v1$$?

## [ Movies ] Open Question : Movies Section: What if Batman & Robin was directed by Tim Burton (Instead of Joel Schumacher)?

If the movie of Batman & Robin (1997) was directed by Tim Burton (Produced, too) instead of Joel Schumacher, what do you think about this cast of characters? Cast: Michael Keaton as Bruce Wayne/Batman (Instead of George Clooney) Marlon Wayans as Dick Grayson/Robin (Instead of Chris O’Donnell) For the villains instead of Mr. Freeze, Poison Ivy, and… Bane Nicolas Cage as Dr. Jonathan Crane/Scarecrow Courtney Love as Dr. Harleen Quinn/Harley Queen And as for the last main character as a heroine character… Alicia Silverstone as Barbara Gordon/Batgirl (Not Barbara Wilson) Any thoughts?

## When using a battlemap, can a lightning bolt be directed between squares to affect both?

Lightning bolt is listed as having a width of 5 feet.

When using a battlemap, can the line of the spell be directed between squares to affect creatures on both sides with full damage?

Does Lightning Bolt affect everyone in its line of effect? suggests this would be true for Pathfinder rules. Its answer suggests that even if the lightning bolt passed a tiny corner of a square – the creature would take full damage. Does this hold true in 5e?

## Shortest path with exactly k edges in a directed and weighted graph big o

how to calculate the big O of Shortest path with exactly k edges in a directed and weighted graph big O

the algorithm is:

## How to find all paths of length up to k between two nodes in a directed graph?

Let’s say I have a directed graph represented as an adjacency matrix, and I’m given two nodes $$u,v$$ and a parameter $$k$$. Let’s also say that the maximal degree of a node in the graph is $$d$$.

What is the most efficient algorithm to find all paths of length $$<=k$$ from $$u$$ to $$v$$?

I know the number of such paths can be calculated efficiently using Dynamic Programming approach, but I’m looking for an algorithm that allows to get a set of actual paths.

It’s clear that such algorithm would have a factor of the number of paths in its time complexity, which has $$k$$ in the exponent, but still, I would like to know what is the best approach for such a problem.