summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-03-30 17:05:54 +0300
committerAlon Levy <alon@pobox.com>2015-04-02 00:31:05 +0300
commit0a01b587fed824bcb4bf054a38f7f203953c8eb1 (patch)
tree92fe76e957d405294fb480643f7a80a0c13dac09
parentfce3af06c569936726432943bd403f3b23cb696c (diff)
client/graph: fix id_to_link_id_set regression w/ inter-graph links
-rw-r--r--src/client/model/graph.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/client/model/graph.js b/src/client/model/graph.js
index 6af804a8..6a67ad63 100644
--- a/src/client/model/graph.js
+++ b/src/client/model/graph.js
@@ -10,9 +10,9 @@ var debug = false;
function Graph(spec) {
- var id_to_node_map = {},
- id_to_link_map = {},
- id_to_link_id_set = {},
+ var id_to_node_map,
+ id_to_link_map,
+ id_to_link_id_set,
diffBus = new Bacon.Bus(),
cached_links,
invalidate_links,
@@ -27,6 +27,8 @@ function Graph(spec) {
util.assert(temporary !== undefined && base !== undefined, "missing inputs");
+ clear();
+
// All operations done on the graph. When the server is used (i.e. always) this
// bus contains the server events, not the user events (most of the time the same just with delay).
this.diffBus = diffBus;
@@ -206,6 +208,13 @@ function Graph(spec) {
dst_id = link.__dst.id;
util.assert(link.id, "missing link id");
id_to_link_map[link.id] = link;
+ // link's nodes may not belong to this graph, check first - we add them if required to the id_to_link_id_set only
+ if (id_to_link_id_set[src_id] === undefined) {
+ id_to_link_id_set[src_id] = [];
+ }
+ if (id_to_link_id_set[dst_id] === undefined) {
+ id_to_link_id_set[dst_id] = [];
+ }
id_to_link_id_set[src_id][dst_id] = 1;
id_to_link_id_set[dst_id][src_id] = 1;
invalidate_links = true;
@@ -767,9 +776,8 @@ function Graph(spec) {
function clear(push_diff) {
push_diff = push_diff === undefined ? true : push_diff;
id_to_node_map = {};
- id_to_node_map = {}
- id_to_link_map = {};
id_to_link_map = {};
+ id_to_link_id_set = {};
invalidate_links = true;
invalidate_nodes = true;
if (push_diff) {