28,399 questions
1585
votes
18
answers
298k
views
Cycles in family tree software
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 ...
473
votes
10
answers
338k
views
Generating statistics from Git repository [closed]
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...
...
393
votes
8
answers
276k
views
Python Graph Library [closed]
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 ...
375
votes
5
answers
663k
views
Plotting two variables as lines using ggplot2 on the same graph
A very newbish question, but say I have data like this:
test_data <-
data.frame(
var0 = 100 + c(0, cumsum(runif(49, -20, 20))),
var1 = 150 + c(0, cumsum(runif(49, -10, 10))),
date = ...
337
votes
13
answers
185k
views
Generating a PNG with matplotlib when DISPLAY is undefined
I am trying to use networkx with Python. When I run this program it get this error. Is there anything missing?
#!/usr/bin/env python
import networkx as nx
import matplotlib
import matplotlib.pyplot
...
237
votes
18
answers
223k
views
Good Java graph algorithm library? [closed]
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 ...
222
votes
7
answers
818k
views
Set Colorbar Range
I have the following code:
import matplotlib.pyplot as plt
cdict = {
'red' : ( (0.0, 0.25, .25), (0.02, .59, .59), (1., 1., 1.)),
'green': ( (0.0, 0.0, 0.0), (0.02, .45, .45), (1., .97, .97)),
...
186
votes
10
answers
194k
views
Force R to stop plotting abbreviated axis labels (scientific notation) - e.g. 1e+00
In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10.
...
186
votes
15
answers
147k
views
Command-line Unix ASCII-based charting / plotting tool
Is there a good command-line UNIX charting / graphing / plotting tool out there? I'm looking for something that will plot xy points on an ASCII graph.
Just to clarify, I'm looking for something that ...
183
votes
12
answers
92k
views
How does Dijkstra's Algorithm and A-Star compare?
I was looking at what the guys in the Mario AI Competition have been doing and some of them have built some pretty neat Mario bots utilizing the A* (A-Star) Pathing Algorithm.
(Video of Mario A* Bot ...
171
votes
7
answers
322k
views
how to draw directed graphs using networkx in python?
I have some nodes coming from a script that I want to map on to a graph. In the below, I want to use Arrow to go from A to D and probably have the edge colored too in (red or something).
This is ...
170
votes
11
answers
202k
views
What is better, adjacency lists or adjacency matrices for graph problems in C++?
What is better, adjacency lists or adjacency matrix, for graph problems in C++?
What are the advantages and disadvantages of each?
167
votes
17
answers
143k
views
Dependency graph of Visual Studio projects
I'm currently migrating a big solution (~70 projects) from VS 2005 + .NET 2.0 to VS 2008 + .NET 3.5. Currently I have VS 2008 + .NET 2.0.
The problem is that I need to move projects one by one to new ...
167
votes
5
answers
768k
views
How to plot multiple functions on the same figure
How can I plot the following 3 functions (i.e. sin, cos and the addition), on the domain t, in the same figure?
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 2*np.pi, 400)
a =...
167
votes
4
answers
171k
views
Representing graphs (data structure) in Python
How can one neatly represent a graph in Python? (Starting from scratch i.e. no libraries!)What data structure (e.g. dicts/tuples/dict(tuples)) will be fast but also memory efficient?One must be able ...
164
votes
7
answers
228k
views
How to trace the path in a Breadth-First Search?
How do you trace the path of a Breadth-First Search, such that in the following example:
If searching for key 11, return the shortest list connecting 1 to 11.
[1, 4, 7, 11]
162
votes
7
answers
85k
views
Why use Dijkstra's Algorithm if Breadth First Search (BFS) can do the same thing faster?
Both can be used to find the shortest path from single source. BFS runs in O(E+V), while Dijkstra's runs in O((V+E)*log(V)).
Also, I've seen Dijkstra used a lot like in routing protocols.
Thus, why ...
156
votes
24
answers
297k
views
Destroy chart.js bar graph to redraw other graph in same <canvas>
I am using the Chart.js library to draw a bar graph, it is working fine, but now I want to destroy the bar graph and make a line graph in the same canvas. I have tried these two ways to clear the ...
144
votes
14
answers
154k
views
Python equivalent of D3.js [closed]
Can anyone recommend a Python library that can do interactive graph visualization?
I specifically want something like d3.js but for python and ideally it would be 3D as well.
I have looked at:
...
140
votes
8
answers
389k
views
Rotating x axis labels in R for barplot
I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below:
barplot(((data1[,1] - average)/average) * 100,
srt = 45,
...
138
votes
8
answers
223k
views
Understanding Time complexity calculation for Dijkstra Algorithm
As per my understanding, I have calculated time complexity of Dijkstra Algorithm as big-O notation using adjacency list given below. It didn't come out as it was supposed to and that led me to ...
136
votes
7
answers
42k
views
How do you represent a graph in Haskell?
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 ...
134
votes
18
answers
146k
views
Difference between Prim's and Dijkstra's algorithms?
What is the exact difference between Dijkstra's and Prim's algorithms? I know Prim's will give a MST but the tree generated by Dijkstra will also be a MST. Then what is the exact difference?
127
votes
5
answers
154k
views
Export a graph to .eps file with R
How do I export a graph to an .eps format file? I typically export my graphs to a .pdf file (using the 'pdf' function), and it works quite well. However, now I have to export to .eps files.
115
votes
3
answers
163k
views
How to use two Y axes in Chart.js v2?
I am trying to create a line chart with two datasets, each with its own Y scale / axis (one to the left, one to the right of the graph) using Chart.js.
This is my code (jsfiddle):
var canvas = ...
115
votes
5
answers
168k
views
How do you plot bar charts in gnuplot?
How do you plot bar charts in gnuplot with text labels?
114
votes
9
answers
165k
views
Breadth First Search time complexity analysis
The time complexity to go over each adjacent edge of a vertex is, say, O(N), where N is number of adjacent edges. So, for V numbers of vertices the time complexity becomes O(V*N) = O(E), where E is ...
111
votes
4
answers
412k
views
matplotlib savefig() plots different from show()
When I use show() to plot the graphs in X, the graphs looks very good. However when I start to use savefig() to generate large amount of graphs, the savefig() generated graphs
' font, lines, polygons ...
110
votes
2
answers
141k
views
Charts for Android [closed]
I am working on a project which have some charts (graphs), tick chart, candlestick chart and range chart. But the problem is, there is no library for that charts. I have got Google chart API for ...
107
votes
2
answers
221k
views
Relationship between dpi and figure size
I have created a figure using matplotlib but I have realized the plot axis and the drawn line gets zoomed out.
Reading this earlier discussion thread, it explains how to set the figure size.
fig, ax =...
106
votes
7
answers
87k
views
Three ways to store a graph in memory, advantages and disadvantages
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 ...
103
votes
3
answers
48k
views
How to view GitHub Contributors Graph for branches other than master?
At https://github.com/yourusername/yourreponame/graphs you can find some nice graphs showing commits over time. However the information is only for the master branch.
How do I see the same ...
102
votes
2
answers
39k
views
Dot graph language - how to make bidirectional edges automatically?
Here is a very simplified example of my Dot graph:
strict digraph graphName {
A->B
B->A
}
This creates
Instead I want a single edge shown between A and B but with a double arrow head. I know ...
98
votes
13
answers
50k
views
Choosing an attractive linear scale for a graph's Y Axis
I'm writing a bit of code to display a bar (or line) graph in our software. Everything's going fine. The thing that's got me stumped is labeling the Y axis.
The caller can tell me how finely they ...
97
votes
12
answers
88k
views
Generate distinctly different RGB colors in graphs
When generating graphs and showing different sets of data it usually a good idea to difference the sets by color. So one line is red and the next is green and so on. The problem is then that when the ...
97
votes
5
answers
63k
views
What's the difference between uniform-cost search and Dijkstra's algorithm?
I was wondering what's the difference between uniform-cost search and Dijkstra's algorithm. They seem to be the same algorithm.
97
votes
13
answers
106k
views
.NET graph library around? [closed]
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:
(source: sourceforge....
93
votes
12
answers
267k
views
What is the maximum number of edges in a directed graph with n nodes? [closed]
What is the maximum number of edges in a directed graph with n nodes? Is there any upper bound?
92
votes
11
answers
88k
views
Finding all cycles in undirected graphs
I need a working algorithm for finding all simple cycles in an undirected graph. I know the cost can be exponential and the problem is NP-complete, but I am going to use it in a small graph (up to 20-...
90
votes
4
answers
28k
views
Comparing object graph representation to adjacency list and matrix representations
I'm currently following Steve Yegge's advice on preparing for a technical programming interview: http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html
In his section on Graphs, he ...
87
votes
5
answers
192k
views
Difference and advantages between dijkstra & A star [duplicate]
I read this:
http://en.wikipedia.org/wiki/A*_search_algorithm
It says A* is faster than using dijkstra and uses best-first-search to speed things up.
If I need the algorithm to run in milliseconds, ...
83
votes
5
answers
118k
views
Common main title of a figure panel compiled with par(mfrow)
I have a compilation of 4 plots drawn together with par(mfrow=c(2,2)). I would like to draw a common title for the 2 above plots and a common title for the 2 below panels that are centered between ...
83
votes
5
answers
350k
views
Python equivalent to 'hold on' in Matlab
Is there an explicit equivalent command in Python's matplotlib for Matlab's hold on? I'm trying to plot all my graphs on the same axes. Some graphs are generated inside a for loop, and these are ...
80
votes
2
answers
90k
views
matplotlib bar graph black - how do I remove bar borders
I'm using pyplot.bar but I'm plotting so many points that the color of the bars is always black. This is because the borders of the bars are black and there are so many of them that they are all ...
80
votes
6
answers
52k
views
Graph auto-layout algorithm
To simplify the problem, I have a graph that contains nodes and edges which are on a 2D plane.
What I want to be able to do is click a button and it make the automatically layout the graph to look ...
77
votes
14
answers
122k
views
Is there any 'out-of-the-box' 2D/3D plotting library for C++? [closed]
I looked at the different options for plotting functions (or other types of graphs) in an interactive window. I mostly use wxWidgets but I'd be open to any other "interfaces".
Looking at what is ...
74
votes
17
answers
139k
views
Cycles in an Undirected Graph
Given an undirected graph G=(V, E) with n vertices (|V| = n), how do you find if it contains a cycle in O(n)?
74
votes
4
answers
53k
views
How to persist a graph data structure in a relational database?
I've considered creating a Vertices table and an Edges table but would building graphs in memory and traversing sub-graphs require a large number of lookups? I'd like to avoid excessive database reads....
73
votes
5
answers
41k
views
What is difference between BFS and Dijkstra's algorithms when looking for shortest path?
I was reading about Graph algorithms and I came across these two algorithms:
Dijkstra's algorithm
Breadth-first search
What is the difference between Dijkstra's algorithm and BFS while looking for ...
73
votes
17
answers
45k
views
Algorithm for "nice" grid line intervals on a graph
I need a reasonably smart algorithm to come up with "nice" grid lines for a graph (chart).
For example, assume a bar chart with values of 10, 30, 72 and 60. You know:
Min value: 10
Max value: 72
...