cyclic

C# : xml serialization of nodes with cyclic links

社会主义新天地 提交于 2019-12-05 07:05:58
I have a class Node something like this : class Node { IEnumerable<Node> inputs; } Which basicly defines a simple graph. I want to serialize my graph to a human-readable form, so normally I'd say xml would be the way to go. But XML wasn't made with cyclic dependencies in mind :) So - what would be the best way to go for serialization of my graph ? I can think of a few ways : ditch XML, create my own format. use XML, tag each node with a unique ID, store connection-lists separate from the Nodes and resolve after loading But I think other people must have had this same problem before, so there

Why is Java prohibiting inheritance of inner interfaces?

雨燕双飞 提交于 2019-12-03 22:32:13
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? 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 is mentioned in the extends or implements clause of C either as a superclass or superinterface, or as a

Determining whether or not a directed or undirected graph is a tree

断了今生、忘了曾经 提交于 2019-12-03 17:39:43
问题 I would like to know of a fast algorithm to determine if a directed or undirected graph is a tree. This post seems to deal with it, but it is not very clear; according to this link, if the graph is acyclic, then it is a tree. But if you consider the directed and undirected graphs below: in my opinion, only graphs 1 and 4 are trees. I suppose 3 is neither cyclic, nor a tree. What needs to be checked to see if a directed or undirected graph is a tree or not, in an efficient way? And taking it

Determining whether or not a directed or undirected graph is a tree

不问归期 提交于 2019-12-03 06:51:48
I would like to know of a fast algorithm to determine if a directed or undirected graph is a tree. This post seems to deal with it, but it is not very clear; according to this link, if the graph is acyclic, then it is a tree. But if you consider the directed and undirected graphs below: in my opinion, only graphs 1 and 4 are trees. I suppose 3 is neither cyclic, nor a tree. What needs to be checked to see if a directed or undirected graph is a tree or not, in an efficient way? And taking it one step ahead: if a tree exists then is it a binary tree or not? For a directed graph: Find the vertex

Problem with cyclic dependencies between types and functions from different files in F#

不问归期 提交于 2019-12-01 08:02:23
My current project uses AST with 40 different types (descriminated unions) and several types from this AST has cyclic dependency. The types are not so big, therefore I put them in one file and applied type ... and ... construction for mutually dependent types. Now, I'm adding functions to make some calculations under each element in AST. Since, there are a lot of functions with several lines of code in them, to make source code cleaner to read, I've separated these functions in different files. It's Ok in the case when cyclic dependency is absent, also works when dependent functions are in the

Problem with cyclic dependencies between types and functions from different files in F#

♀尐吖头ヾ 提交于 2019-12-01 07:40:43
问题 My current project uses AST with 40 different types (descriminated unions) and several types from this AST has cyclic dependency. The types are not so big, therefore I put them in one file and applied type ... and ... construction for mutually dependent types. Now, I'm adding functions to make some calculations under each element in AST. Since, there are a lot of functions with several lines of code in them, to make source code cleaner to read, I've separated these functions in different

Finding all cycles in a directed graph using recursive backtracking

会有一股神秘感。 提交于 2019-12-01 00:13:55
I am working on finding cycles in directed graph using recursive backtracking. There is a suggested pseudocode for this here , which is here: dfs(adj,node,visited): if (visited[node]): if (node == start): "found a path" return; visited[node]=YES; for child in adj[node]: dfs(adj,child,visited) visited[node]=NO; Call the above function with the start node: visited = {} dfs(adj,start,visited) While this is not the most efficient algorithm when compared to Tarjans algorithm , this is simple enough me for me to understand. Currently, this code does not have a count of number cycles detected. I

Finding all cycles in a directed graph using recursive backtracking

对着背影说爱祢 提交于 2019-11-30 18:34:06
问题 I am working on finding cycles in directed graph using recursive backtracking. There is a suggested pseudocode for this here, which is here: dfs(adj,node,visited): if (visited[node]): if (node == start): "found a path" return; visited[node]=YES; for child in adj[node]: dfs(adj,child,visited) visited[node]=NO; Call the above function with the start node: visited = {} dfs(adj,start,visited) While this is not the most efficient algorithm when compared to Tarjans algorithm , this is simple enough

How do find the longest path in a cyclic Graph between two nodes?

时间秒杀一切 提交于 2019-11-30 07:27:40
问题 I already solved most the questions posted here, all but the longest path one. I've read the Wikipedia article about longest paths and it seems any easy problem if the graph was acyclic, which mine is not. How do I solve the problem then? Brute force, by checking all possible paths? How do I even begin to do that? I know it's going to take A LOT on a Graph with ~18000. But I just want to develop it anyway, cause it's required for the project and I'll just test it and show it to the instructor

How to detect if a directed graph is cyclic?

…衆ロ難τιáo~ 提交于 2019-11-27 19:43:33
How can we detect if a directed graph is cyclic? I thought using breadth first search, but I'm not sure. Any ideas? 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. What you really need, I believe, is a topological sorting algorithm like the one described here: http://en.wikipedia.org/wiki