public
/
ack.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
363d1d0
)
Massive graph performance boost by checking to see whether an edge already
author
David Given
<dg@cowlark.com>
Fri, 16 Dec 2016 23:21:27 +0000
(
00:21
+0100)
committer
David Given
<dg@cowlark.com>
Fri, 16 Dec 2016 23:21:27 +0000
(
00:21
+0100)
exists in the hash table before trying to add it.
modules/src/data/bigraph.c
patch
|
blob
|
history
diff --git
a/modules/src/data/bigraph.c
b/modules/src/data/bigraph.c
index
1e6a841
..
4499563
100644
(file)
--- a/
modules/src/data/bigraph.c
+++ b/
modules/src/data/bigraph.c
@@
-130,10
+130,16
@@
void graph_add_edge(struct graph* g, void* data1, void* data2)
struct vertex* v1 = find_or_add_vertex(g, data1);
struct vertex* v2 = find_or_add_vertex(g, data2);
struct edgenode* e;
+ struct edgenode template;
if (v1 == v2)
return;
+ template.this = v1;
+ template.other = v2;
+ if (hashtable_contains(&g->edges, &template))
+ return;
+
add_edge(v1, v2);
e = add_edge(v2, v1);