Set Colorbar Range

Using vmin and vmax forces the range for the colors. Here’s an example: import matplotlib as m import matplotlib.pyplot as plt import numpy as np 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)), ‘blue’ : ( (0.0, … Read more

Generating a random DAG

I cooked up a C program that does this. The key is to ‘rank’ the nodes, and only draw edges from lower ranked nodes to higher ranked ones. The program I wrote prints in the DOT language. Here is the code itself, with comments explaining what it means: #include <stdio.h> #include <stdlib.h> #include <time.h> #define … Read more

What do line colors in git log –graph mean?

The colors are merely meant to help you view the lines as distinct from other lines. To answer question #1, they are assigned not pseudo-randomly, but rather sequentially, each time git log –graph picks a new “column number”. Unfortunately there are two issues I know of. Both tie into your question #2. Here is the … Read more

Finding all the shortest paths between two nodes in unweighted undirected graph

As a caveat, remember that there can be exponentially many shortest paths between two nodes in a graph. Any algorithm for this will potentially take exponential time. That said, there are a few relatively straightforward algorithms that can find all the paths. Here’s two. BFS + Reverse DFS When running a breadth-first search over a … Read more

Graph Databases – betting the company on it?

Disclaimer: I work for/with Neo4j Just talking about the maturity here (not technicalities) – Neo Technology as a company with more than 50 employees, $25M funding and a thriving user-base with half a million downloads, 30k new databases running each month and an active community won’t go away. You can also check the SO questions … Read more

How to convert to D3’s JSON format?

There’s no prescribed format, as you can usually redefine your data through various accessor functions (such as hierarchy.children) and array.map. But the format you quoted is probably the most convenient representation for trees because it works with the default accessors. The first question is whether you intend to display a graph or a tree. For … Read more

How should I update the data of a plot in Matlab?

Short answer : always use Set(‘Xdata’,…’). Example code: function PlotUpdate() x = 0:.1:8; y = sin(x); h = plot(x,y); y = sin(x.^3); set(h,’XData’,x,’YData’,y); end Long answer: There are three relevant measures by which one should choose the best method. Code clarity – How easy it is for someone to read your code? Runtime – How … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)