algorithm,directed-acyclic-graphs

Finding longest path in a DAG doesn't really "care" about only positive weights, it is done using Dynamic Programming (DP) by following the formula: D(target) = 0 D(i) = max { D(j) + w(i,j) | for each edge (i,j) } The above is finding D(v), which is the maximal length...

algorithm,graph,vertex,directed-acyclic-graphs,topological-sort

a. Prove that for every DAG the above function is uniquely defined, i.e. it's the only function that satisfies conditions 1,2 and 3. Maybe I am missing something, but this seems really obvious to me: if you define it as the minimum that satisfies those conditions, how can there...

algorithm,shortest-path,directed-acyclic-graphs,floyd-warshall

Yes, Floyd Warshall can give a correct answer for your problems, can be proved like using Floyd Warshall to find the shortest path between all pairs in graph. Or you can multiply each edges with (-1), and solve your problem like finding the shortest path between all pairs, then multiply...

mysql,max,directed-acyclic-graphs

You should be able to use the GREATEST() function in MySQL. Try this: SELECT GREATEST( (SELECT MAX(id_item) FROM material), (SELECT MAX(id_collection) FROM material)); This will select the largest item, whether that's the MAX(id_item) or MAX(id_collection). EDIT Something that may look a little cleaner. The GREATEST() function takes the largest of...

algorithm,directed-acyclic-graphs

This is pretty simple, once you realise that notionally only the direction of the edges in the DAG has changed. Instead of the Parent ---> Child node relationship, you have a Child ---> Parent relationship. As such, all you need to do is construct a DAG from the given relationships,...

algorithm,directed-acyclic-graphs

The solution is valid since H has no successors that mentioned before H and no predecessors that are mentioned after H. It's not any stranger than the fact that the graph A <- B -> C (where B is "unreachable") can be topologically sorted as B, A, C ...

algorithm,memory,graph,compiler-optimization,directed-acyclic-graphs

Actually, in some sense this problem is easier than the graph coloring problem, because the decision version of this problem is a special case of the decision version of the Combined Register Allocation and Instruction Scheduling Problem (CRISP), which is simpler to solve than the graph coloring problem (at least...

r,graphviz,dot,rank,directed-acyclic-graphs

Here's my answer. Suggestions welcome. gR is an object of formal class GRAPHNEL gx <- layoutGraph(gR) #can also add node attributes, sublists here x <- [email protected]@nodes$nodeX y <- [email protected]@nodes$nodeY #x and y are named vectors with node names and x / y coordinates #to get the names of the nodes...

caching,graph,varnish,directed-acyclic-graphs,cache-invalidation

There's no support for exactly what you are asking for but as a workaround you can put tags in your headers as to what comments they are dependent on. For example sending a: x-depend-comments: 2578 2579 2580 And then at an update of a comment you can send a ban...

c++,destructor,directed-acyclic-graphs

In the Node::~Node() function, seems like this is a one of the m_offsprings. So after the first iteration of the for (int i(0); i<m_dad->m_offsprings.size();++i) { if (m_dad->m_offsprings[i]) { m_dad->m_offsprings[i]->m_dad=nullptr; } } this->m_dad becomes nullptr. After that you are trying to dereference it in m_dad->m_offsprings.size(). To fix this, check that address...

algorithm,graph,dynamic-programming,directed-acyclic-graphs

Imagine that there is a directed edge between two states if we can go from the first state to the second one(of course, a state can consist of several parameters). There are no cycles in this graph, so it is DAG. So visualizing a DAG itself is not hard(you can...

algorithm,directed-acyclic-graphs

Let's assume your nodes are numbered from 1 to n. There's a simple solution: Create an array D of size n, with values initialized to 0. Then walk through all edges (v, w) and increment D[w] by one. In the end D[w] will be the in-degree of vertex w.

python,multithreading,python-2.7,directed-acyclic-graphs

Have one master thread push items to a queue once they are ready for being processsed. Then have a pool of workers listen on the queue for tasks to work on. (Python provides a synchronized queue in the Queue module, renamed to lower-case queue in Python 3). The master first...

algorithm,graph,graph-algorithm,directed-acyclic-graphs

Let's assume that f(i, j) is the number of paths from i to j vertex. Initially(I assume that the graph is empty, if it is not the case you can add all edges using the add operation) f(i, j) = 1 if i = j and 0 otherwise. To add...

algorithm,directed-acyclic-graphs

The time requirement is the maximum weight of a path in the acyclic directed graph. Two linear-time traversals yield, for each node, the maximum weight of a path ending with that node and the maximum weight of a path starting with that node. Now we can find the maximum length...

java,data-structures,directed-acyclic-graphs,adjacency-matrix

There are many options: You could add a pointer back to the header to the ListNode class, turning it into a full edge representation. You could change your representation to have dedicated Vertex and Edge classes. You could return a node pair (e.g. an ListNode array of size 2) containing...

algorithm,dijkstra,directed-acyclic-graphs

Consider the graph (directed 1 -> 2, 2-> 4, 4 -> 3, 1 -> 3, 3 -> 5): 1---(2)---3--(2)--5 | | (3) (2) | | 2--(-10)--4 The minimum path is 1 - 2 - 4 - 3 - 5, with cost -3. However, Dijkstra will set d[3] = 2, d[2]...