EzDevInfo.com

graph interview questions

Top graph frequently asked interview questions

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 = seq.Date(as.Date("2002-01-01"), by="1 month", length.out=100))

How can I plot both time series var0 and var1 on the same graph, with date on the x-axis, using ggplot2? Bonus points if you make var0 and var1 different colours, and can include a legend!

I'm sure this is very simple, but I can't find any examples out there.


Source: (StackOverflow)

Visualizing Undirected Graph That's Too Large for GraphViz?

I need advice for rendering an undirected graph with 178,000 nodes and 500,000 edges. I've tried Neato, Tulip, and Cytoscape. Neato doesn't even come remotely close, and Tulip and Cytoscape claim they can handle it but don't seem to be able to. (Tulip does nothing and Cytoscape claims to be working, and then just stops.)

I'd just like a vector format file (ps or pdf) with a remotely reasonable layout of the nodes.


Source: (StackOverflow)

Advertisements

.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: alt text

I also need it to have drawing capabilities.


Source: (StackOverflow)

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 .NET framework ensuring that no .NET 2.0 project references .NET 3.5 project. Is there any tool that would give me a nice graph of project dependencies?


Source: (StackOverflow)

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 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)

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 googled around, but I don't find anything that particularly leaps out at me.

Anyone have any good recommendations?


Source: (StackOverflow)

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...

  • 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)

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 webview. this is the link for example of candlestick chart based on Google chart api http://rpiesnikowski.blogspot.in/2011/03/android-candlestick-chart-with-google.html .


Source: (StackOverflow)

Three ways to store a graph in memory, advantages and disadvantages

There are three ways to store a graph in memory:

  1. Nodes as objects and edges as pointers
  2. A matrix containing all edge weights between numbered node x and node y
  3. 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)

Graph Algorithm To Find All Connections Between Two Arbitrary Vertices

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)

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 = 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)

What's the fastest, pure Javascript, Graph visualization toolkit? [closed]

This question is about toolkits which draw graphs (those things composed of vertices and edges), not generic plots.

The tool must be able to get a set of vertices and edges, calculate their layout, and display them either using the canvas tag, or SVG, that is be compatible with HTML5.

Flash-based tools and java applets are out.

to serve as unified benchmark, please measure and report how long it takes for the toolkit to layout and draw a Barabasi-Albert graph with 100 vertices and 5 edges per node.

This python lybrary shows how to generate it and exports it to many formats:

http://networkx.lanl.gov/tutorial/tutorial.html#graph-generators-and-graph-operations

Please indicate browser and CPU.


Source: (StackOverflow)

How do you plot bar charts in gnuplot?

How do you plot bar charts in gnuplot with text labels?


Source: (StackOverflow)

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 will output a graph in ASCII (like ascii-art style), so I can use it over an interactive shell session without needing X.


Source: (StackOverflow)

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 thing faster?


Source: (StackOverflow)