Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oblongmana/5820111 to your computer and use it in GitHub Desktop.
Save Oblongmana/5820111 to your computer and use it in GitHub Desktop.
rfong's graph editor fork doesn't currently work due to using a raw.github script. This works around that using the rawgithub.com workaround instead
//Import script using rawgithub workaround site (as opposed to raw.github which doesn't work and is currently used on the page)
var jq = document.createElement('script');
jq.src = "https://rawgithub.com/rfong/graph-editor.js/master/build/graph-editor.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// Create Graph inputs
var K4_graph = JSON.stringify(
{"vertices": ["0", "1", "2", "3"],
"edges": [["0", "1", "10"], ["0", "2", null], ["0", "3", "armadillo"], ["1", "2", "57.382"], ["1", "3", "23potato"], ["2", "3", null]],
"name": "G",
"pos": {"0": [0.0, 1.0], "1": [-1.0, 0.0], "2": [0.0, -1.0], "3": [1.0, 0.0]}});
var cube = '{"edges": [["000", "001", null], ["000", "010", null], ["000", "100", null], ["001", "011", null], ["001", "101", null], ["010", "011", null], ["010", "110", null], ["011", "111", null], ["100", "101", null], ["100", "110", null], ["101", "111", null], ["110", "111", null]], "vertices": ["000", "001", "010", "011", "100", "101", "110", "111"], "name": "G", "pos": {"010": [0.50000000000000011, 0.8660254037844386], "011": [3.3306690738754696e-16, 1.7320508075688772], "001": [-0.49999999999999978, 0.86602540378443871], "000": [0.0, 0.0], "111": [1.0000000000000002, 1.7320508075688772], "110": [1.5, 0.8660254037844386], "100": [1.0, 0.0], "101": [0.50000000000000022, 0.86602540378443871]}}';
//Get the graph editor up and running
hljs.initHighlightingOnLoad();
my_graph_editor1 = new GraphEditor('#graph_ed1', {
JSONdata : K4_graph,
width: 800,
height: 600
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment