graph
A mathematical graph/network library written in PHP
I am the developer of some family tree software (written in C++ and Qt). I had no problems until one of my customers mailed me a bug report. The problem is that the customer has two children with their own daughter, and, as a result, he can't use my software because of errors.
Those errors are the result of my various assertions and invariants about the family graph being processed (for example, after walking a cycle, the program states that X can't be both father and grandfather of Y).
How can I resolve those errors without removing all data assertions?
Source: (StackOverflow)
Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried JGraph and found it ok, and there are a lot of different ones in google. Are there any that people are actually using successfully in production code or would recommend?
To clarify, I'm not looking for a library that produces graphs/charts, I'm looking for one that helps with Graph algorithms, eg minimum spanning tree, Kruskal's algorithm Nodes, Edges, etc. Ideally one with some good algorithms/data structures in a nice Java OO API.
Source: (StackOverflow)
I'm writing a python application that will make heavy use of a graph data structure. Nothing horribly complex, but I'm thinking some sort of graph/graph-algorithms library would help me out. I've googled around, but I don't find anything that particularly leaps out at me.
Anyone have any good recommendations?
Source: (StackOverflow)
I have an array of timestamps in the format (HH:MM:SS.mmmmmm) and another array of floating point numbers, each corresponding to a value in the timestamp array.
Can I plot time on the x axis and the numbers on the y-axis using matplotlib? I was trying to but somehow it was only accepting arrays of floats.How can I get it to plot the time? Do i have to modify the format in anyway?
Source: (StackOverflow)
How can I find (iterate over) ALL the cycles in a directed graph from/to a given node?
For example, I want something like this:
A->B->A
A->B->C->A
but not:
B->C->B
Source: (StackOverflow)
There are three ways to store a graph in memory:
- Nodes as objects and edges as pointers
- A matrix containing all edge weights between numbered node x and node y
- A list of edges between numbered nodes
I know how to write all three, but I'm not sure I've thought of all of the advantages and disadvantages of each.
What are the advantages and disadvantages of each of these ways of storing a graph in memory?
Source: (StackOverflow)
I want to plot social network visualization, but cannot do much programming. Does anyone know a piece of software that can do network visualisations and does not require coding (or at least little coding)?
Source: (StackOverflow)
I'm looking for some good tools/scripts that allow me to generate a few statistics from a git repository. I've seen this feature on some code hosting sites, and they contained information like...
- commits per author
- commits per day/week/year/etc.
- lines of code over time
- graphs
- ... much more
Basically I just want to get an idea how much my project grows over time, which developer commits most code, and so on.
Source: (StackOverflow)
Current situation : I'm trying to extract segments from an image. Thanks to openCV's findContours()
method, I now have a list of 8-connected point for every contours. However, these lists are not directly usable, because they contain a lot of duplicates.
The problem : Given a list of 8-connected points, which can contain duplicates, extract segments from it.
Possible solutions :
- At first, I used openCV's
approxPolyDP()
method. However, the results are pretty bad... Here is the zoomed contours :
Here is the result of approxPolyDP()
: (9 segments! Some overlap)
but what I want is more like :
It's bad because approxPolyDP()
can convert something that "looks like several segments" in "several segments". However, what I have is a list of points that tend to iterate several times over themselves.
For example, if my points are:
0 1 2 3 4 5 6 7 8
9
Then, the list of point will be 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 9
... And if the number of points become large (>100) then the segments extracted by approxPolyDP()
are unfortunately not duplicates (i.e : they overlap each other, but are not stricly equal, so I can't just say "remove duplicates", as opposed to pixels for example)
- Perhaps, I've got a solution, but it's pretty long (though interesting). First of all, for all 8-connected list, I create a sparse matrix (for efficiency) and set the matrix values to 1 if the pixel belongs to the list. Then, I create a graph, with nodes corresponding to pixels, and edges between neighbouring pixels. This also means that I add all the missing edges between pixels (complexity small, possible because of the sparse matrix). Then I remove all possible "squares" (4 neighouring nodes), and this is possible because I am already working on pretty thin contours. Then I can launch a minimal spanning tree algorithm. And finally, I can approximate every branch of the tree with openCV's
approxPolyDP()
Here are fantastic pictures (thanks Paint!) of the original list, and the associated graph. Then, when I add edges between neighbours. And finally, when I remove edges and make a minimum spanning tree (not useful here)
To sum up : I've got a tedious method, that I've not yet implemented as it seems error-prone. However, I ask you, people at StackOverflow : are there other existing methods, possibly with good implementations?
Edit : To clarify, once I have a tree, I can extract "branches" (branches start at leaves or nodes linked to 3 or more other nodes) Then, the algorithm in openCV's approxPolyDP()
is the Ramer–Douglas–Peucker algorithm, and here is the Wikipedia picture of what it does :
With this picture, it is easy to understand why it fails when points may be duplicates of each other
Another edit : In my method, there is something that may be interesting to note. When you consider points located in a grid (like pixels), then generally, the minimal spanning tree algorithm is not useful because there are many possible minimal trees
X-X-X-X
|
X-X-X-X
is fundammentally very different from
X-X-X-X
| | | |
X X X X
but both are minimal spanning trees
However, in my case, my nodes rarely form clusters because they are supposed to be contours, and there is already a thinning algorithm that runs beforehand in the findContours()
.
Answer to Tomalak's comment :
If DP algorithm returns 4 segments (the segment from the point 2
to the center being there twice) I would be happy! Of course, with good parameters, I can get to a state where "by chance" I have identical segments, and I can remove duplicates. However, clearly, the algorithm is not designed for it.
Here is a real example with far too many segments :
Source: (StackOverflow)
A point in 3-d is defined by (x,y,z). Distance d between any two points (X,Y,Z) and (x,y,z) is d= Sqrt[(X-x)^2 + (Y-y)^2 + (Z-z)^2].
Now there are a million entries in a file, each entry is some point in space, in no specific order. Given any point (a,b,c) find the nearest 10 points to it. How would you store the million points and how would you retrieve those 10 points from that data structure.
Source: (StackOverflow)
I am trying to determine the best time efficient algorithm to accomplish the task described below.
I have a set of records. For this set of records I have connection data which indicates how pairs of records from this set connect to one another. This basically represents an undirected graph, with the records being the vertices and the connection data the edges.
All of the records in the set have connection information (i.e. no orphan records are present; each record in the set connects to one or more other records in the set).
I want to choose any two records from the set and be able to show all simple paths between the chosen records. By "simple paths" I mean the paths which do not have repeated records in the path (i.e. finite paths only).
Note: The two chosen records will always be different (i.e. start and end vertex will never be the same; no cycles).
For example:
If I have the following records:
A, B, C, D, E
and the following represents the connections:
(A,B),(A,C),(B,A),(B,D),(B,E),(B,F),(C,A),(C,E),
(C,F),(D,B),(E,C),(E,F),(F,B),(F,C),(F,E)
[where (A,B) means record A connects to record B]
If I chose B as my starting record and E as my ending record, I would want to find all simple paths through the record connections that would connect record B to record E.
All paths connecting B to E:
B->E
B->F->E
B->F->C->E
B->A->C->E
B->A->C->F->E
This is an example, in practice I may have sets containing hundreds of thousands of records.
Source: (StackOverflow)
It's easy enough to represent a tree or list in haskell using algebraic data types. But how would you go about typographically representing a graph? It seems that you need to have pointers. I'm guessing you could have something like
type Nodetag = String
type Neighbours = [Nodetag]
data Node a = Node a Nodetag Neighbours
And that would be workable. However it feels a bit decoupled; The links between different nodes in the structure don't really "feel" as solid as the links between the current previous and next elements in a list, or the parents and children of a node in a tree. I have a hunch that doing algebraic manipulations on the graph as I defined it would be somewhat hindered by the level of indirection introduced through the tag system.
It is primarily this feeling of doubt and perception of inelegance that causes me to ask this question. Is there a better/more mathematically elegant way of defining graphs in Haskell? Or have I stumbled upon something inherently hard/fundamental? Recursive data structures are sweet, but this seems to be something else. A self referential data structure in a different sense to how trees and lists are self referential. It's like lists and trees are self referential at the type level, but graphs are self referential at the value level.
So what's really going on?
Source: (StackOverflow)
I am looking for Graph libraries for .net. Are there any out?
ps: I mean GRAPH libraries, not graphics nor charting libraries!
edit: What I mean is graphs, from graph theory:
I also need it to have drawing capabilities.
Source: (StackOverflow)
I understand the differences between DFS (Depth First Search) and BFS (Breadth First Search), but I'm interested to know when it's more practical to use one over the other?
Could anyone give any examples of how DFS would trump BFS and vice versa?
Source: (StackOverflow)