@@ -895,7 +895,18 @@ function Neo4jD3(_selector, _options) {
895
895
}
896
896
897
897
function updateNodes ( n ) {
898
- Array . prototype . push . apply ( nodes , n ) ;
898
+ var distinctNodes = [ ] ;
899
+ if ( nodes . length > 0 ) {
900
+ n . forEach ( function ( item , index , array ) {
901
+ if ( contains ( nodes , item . id ) )
902
+ return ;
903
+ else
904
+ distinctNodes . push ( item ) ;
905
+ } ) ;
906
+ } else
907
+ distinctNodes = n ;
908
+
909
+ Array . prototype . push . apply ( nodes , distinctNodes ) ;
899
910
900
911
node = svgNodes . selectAll ( '.node' )
901
912
. data ( nodes , function ( d ) { return d . id ; } ) ;
@@ -912,7 +923,18 @@ function Neo4jD3(_selector, _options) {
912
923
}
913
924
914
925
function updateRelationships ( r ) {
915
- Array . prototype . push . apply ( relationships , r ) ;
926
+ var distinctRelations = [ ] ;
927
+ if ( relationships . length > 0 ) {
928
+ r . forEach ( function ( item , index , array ) {
929
+ if ( contains ( relationships , item . id ) )
930
+ return ;
931
+ else
932
+ distinctRelations . push ( item ) ;
933
+ } ) ;
934
+ } else
935
+ distinctRelations = r ;
936
+
937
+ Array . prototype . push . apply ( relationships , distinctRelations ) ;
916
938
917
939
relationship = svgRelationships . selectAll ( '.relationship' )
918
940
. data ( relationships , function ( d ) { return d . id ; } ) ;
0 commit comments