From 981497b5d127c4e1c63695c02e97b73f15ce48b0 Mon Sep 17 00:00:00 2001
From: Anton Skorokhod <anton@nsl.cz>
Date: Sat, 8 Apr 2017 18:48:24 +0200
Subject: [PATCH 1/3] Remove also all connections during peer remove

---
 index.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/index.js b/index.js
index 207cce6..bd16699 100644
--- a/index.js
+++ b/index.js
@@ -334,6 +334,13 @@ function TorrentGraph (root) {
     var index = getNodeIndex(id)
     if (index === -1) throw new Error('remove: node does not exist')
     model.nodes.splice(index, 1)
+
+    for (var i = model.links.length - 1; i >= 0; i -= 1) {
+      if ((model.links[i].source.id == id) || (model.links[i].target.id == id)) {
+        model.links.splice(i, 1)
+      }
+    }
+
     update()
   }
 

From 1db02f3e5c63a28d75a730d2f9eea961f899eeff Mon Sep 17 00:00:00 2001
From: Anton Skorokhod <anton@nsl.cz>
Date: Sat, 8 Apr 2017 19:04:47 +0200
Subject: [PATCH 2/3] Fix == to ===

---
 index.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/index.js b/index.js
index bd16699..f669c1a 100644
--- a/index.js
+++ b/index.js
@@ -336,7 +336,7 @@ function TorrentGraph (root) {
     model.nodes.splice(index, 1)
 
     for (var i = model.links.length - 1; i >= 0; i -= 1) {
-      if ((model.links[i].source.id == id) || (model.links[i].target.id == id)) {
+      if ((model.links[i].source.id === id) || (model.links[i].target.id === id)) {
         model.links.splice(i, 1)
       }
     }

From d5142189bb7c8f89526f5e3ad9e75da364a7c207 Mon Sep 17 00:00:00 2001
From: Anton Skorokhod <anton@nsl.cz>
Date: Wed, 26 Apr 2017 12:56:07 +0200
Subject: [PATCH 3/3] style fixes

---
 index.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/index.js b/index.js
index addb9ca..56bf2f9 100644
--- a/index.js
+++ b/index.js
@@ -139,7 +139,7 @@ P2PGraph.prototype.remove = function (id) {
       self._model.links.splice(i, 1)
     }
   }
-  
+
   self._model.nodes.splice(index, 1)
   self._update()
 }