cyclic

How to remove cycles in an unweighted directed graph, such that the number of edges is maximised?

随声附和 提交于 2020-04-07 14:59:10
问题 Let G be an unweighted directed graph containing cycles. I'm looking for an algorithm which finds/creates all acyclic graphs G', composed of all vertices in G and a subset of edges of G, just small enough to make G' acyclic. More formal: The desired algorithm consumes G and creates a set of acyclic graphs S, where each graph G' in S satisfies following properties: G' contains all vertices of G. G' contains a subset of edges of G, such that G' is acyclic. The number of edges of G' is maximised

CRC calculating and BCH encoding [THEORY]

冷暖自知 提交于 2019-12-24 10:42:36
问题 I have question about BCH Encoding. Is BCH Encoding is the same operation like CRC remainder calculation? M(x) mod G(x) = R(x) and R(x) is my BCH code? 回答1: You are pretty much correct. To be precise, if your generator polynomial is g(x) and your block size is n , then the valid code words are the multiples of g(x) with degree < n . Lets say you have a message m(x) of degree < k , and g(x) has degree n-k : There are different ways you could turn your message into a unique valid code word. m(x

Is an infinite list of ones sane?

戏子无情 提交于 2019-12-23 08:17:01
问题 In Prolog, is the unification X = [1|X] a sane way to get an infinite list of ones? SWI-Prolog does not have any problem with it, but GNU Prolog simply hangs. I know that in most cases I could replace the list with one(1). one(X) :- one(X). but my question is explicitly if one may use the expression X = [1|X], member(Y, X), Y = 1 in a "sane" Prolog implementation. 回答1: In Prolog, is the unification X = [1|X] a sane way to get an infinite list of ones? It depends on whether or not you consider

The Elegant way to handle Cyclic Event in Java?

房东的猫 提交于 2019-12-22 05:50:24
问题 i think this not a specific problem to me; everybody might have encountered this issue before. To properly illustrate it, here's a simple UI: As you can see, those two spinners are controlling a single variable -- "A". The only difference is that they control it using different views. Since these two spinners' displaying values are synchronized, cyclic event shows up. If i change the top spinner, "A" will be changed and the bottom spinner's value will also be updated accordingly. However ,

Why is Java prohibiting inheritance of inner interfaces?

大城市里の小女人 提交于 2019-12-21 07:12:07
问题 I.e. why is the following "cyclic dependency" not possible? public class Something implements Behavior { public interface Behavior { // ... } } Since interfaces don't reference the outer class this should be allowed; however, the compiler is forcing me to define those interfaces outside the class. Is there any logical explanation for this behavior? 回答1: Relevant rules in spec: http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.4 A class C directly depends on a type T if T

How to detect if a directed graph is cyclic?

泄露秘密 提交于 2019-12-17 15:43:19
问题 How can we detect if a directed graph is cyclic? I thought using breadth first search, but I'm not sure. Any ideas? 回答1: Usually depth-first search is used instead. I don't know if BFS is applicable easily. In DFS, a spanning tree is built in order of visiting. If a the ancestor of a node in the tree is visited (i.e. a back-edge is created), then we detect a cycle. See http://www.cs.nyu.edu/courses/summer04/G22.1170-001/6a-Graphs-More.pdf for a more detailed explanation. 回答2: What you really

JAVA/JNI - Load native DLL with circular dependency

蓝咒 提交于 2019-12-12 02:56:35
问题 I try to load c++ code in my java project with JNI. I have many several DLL to load, and unfortunately there is a cyclic dependency between two of them : dll A needs dll B which in turns need dll A ! I know it is a bad programming design to have circular dependencies between DLL, but in my project the c++ code is a black box to me. Is there any way to load DLL with a cyclic dependency ? Thanks for your help. jpsi Details: My code is quite simple: System.loadLibrary("myDLLA"); // needs dll B

Circular template reference structure

会有一股神秘感。 提交于 2019-12-12 01:29:09
问题 I have a ploblem about circular template reference. I want to make a tree using class node and class edge as following; template <typename EdgeT> class node { public: std::vector<EdgeT> edge_out; std::vector<EdgeT> edge_in; }; template <typename NodeT> class edge { public: NodeT* src; NodeT* dst; int weight; }; template <typename NodeT, typename EdgeT> class graph { public: std::vector<NodeT> nodes; }; I found that I cannot declare graph class ex: graph< node, edge > g; // <--- this cannot be

Construct a circular loop in python [duplicate]

丶灬走出姿态 提交于 2019-12-11 16:43:10
问题 This question already has answers here : Pairwise circular Python 'for' loop (17 answers) Closed 3 years ago . I want to loop a list over a cycle. ex: I have three elements in the array L = [1,2,3] I want to get the output as L[0],L[1] L[1],L[2] L[2],L[0] Is there a easy way get the slightly different output L[0],L[1] L[1],L[2] L[0],L[2] 回答1: Using modulus operator >>> a = [1,2,3] >>> for x in range(10): print a[x % len(a)] Using itertools.cycle >>> iterator = cycle(a) >>> for _ in range(10):

Is backtracking absolutely necessary for cycle detection using DFS in directed graph?

痞子三分冷 提交于 2019-12-10 10:53:27
问题 I came across this SO post where it is suggested that cycle detection using DFS in a directed graph is faster because of backtracking. Here I quote from that link: Depth first search is more memory efficient than breadth first search as you can backtrack sooner. It is also easier to implement if you use the call stack but this relies on the longest path not overflowing the stack. Also if your graph is directed then you have to not just remember if you have visited a node or not, but also how