Questions tagged [graph]

This "graph" tag refers to a graphical data presentation, e.g. chart or diagram. For the mathematical concept use [graph-theory].

A graph is a visual representation of the relationship between two or more variables. Graphs are especially useful for recognizing broad trends or patterns in large data-sets, and thus are often used for visualising scientific data.

Related tags:


For graphs in discrete mathematics (consisting of nodes/vertices and edges/arcs/relationships which connect pairs of these nodes/vertices), please use . You might also include one of the following tags:

  • for questions on graph-related algorithms.
  • for questions on database technologies for persisting and querying graphs.
28721 questions
154
votes
7 answers

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]
Christopher Markieta
  • 5,674
  • 10
  • 43
  • 60
154
votes
7 answers

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 use Dijkstra's algorithm if BFS can do the same…
gingercat
  • 1,543
  • 2
  • 10
  • 4
148
votes
3 answers

Move X-Axis label downwards, but not X-Axis Ticks in matplotlib

I'm using Matplotlib to plot a histogram. Using tips from my previous question: Matplotlib - label each bin, I've more or less got the kinks worked out. There's one final issue - previously - the x-axis label ("Time (in milliseconds)") was being…
victorhooi
  • 16,775
  • 22
  • 90
  • 113
135
votes
14 answers

Python equivalent of D3.js

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: NetworkX - it only does Matplotlib plots and those…
Eiyrioü von Kauyf
  • 4,481
  • 7
  • 32
  • 41
133
votes
7 answers

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 guessing you could have something like type Nodetag =…
132
votes
23 answers

Destroy chart.js bar graph to redraw other graph in same

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 canvas: var grapharea =…
Syed Uzair Uddin
  • 3,296
  • 7
  • 31
  • 47
129
votes
18 answers

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
8 answers

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, adj = 1, xpd = TRUE, …
David
  • 2,834
  • 6
  • 26
  • 31
124
votes
5 answers

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.
mStudent
  • 1,568
  • 3
  • 15
  • 21
122
votes
8 answers

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 understand it step by step. Each vertex can be…
Meena Chaudhary
  • 9,909
  • 16
  • 60
  • 94
113
votes
5 answers

How do you plot bar charts in gnuplot?

How do you plot bar charts in gnuplot with text labels?
tatwright
  • 37,567
  • 6
  • 21
  • 9
111
votes
3 answers

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 = document.getElementById('chart'); new Chart(canvas, { …
just.me
  • 2,155
  • 5
  • 16
  • 25
110
votes
2 answers

Charts for Android

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 candlestick chart. But I don't want graph/chart in a…
ASP
  • 1,974
  • 3
  • 18
  • 30
109
votes
8 answers

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 the total number of edges in the graph. Since…
Meena Chaudhary
  • 9,909
  • 16
  • 60
  • 94
105
votes
7 answers

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 know how to write all three, but I'm not sure…
Dean J
  • 39,360
  • 16
  • 67
  • 93