From 56c212247c73867aa9434e56cb7bfdbe96d88667 Mon Sep 17 00:00:00 2001 From: Rodrigo Morais <58960796+rodigu@users.noreply.github.com> Date: Wed, 6 Apr 2022 18:17:53 -0700 Subject: [PATCH] :bug: removed addEdge vertex order for undirected --- network.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/network.ts b/network.ts index 8e56e5f..6e9f4b6 100644 --- a/network.ts +++ b/network.ts @@ -70,6 +70,12 @@ export class Network { .reduce((prev, curr) => prev + curr); } + get product(): number { + return this.edge_list + .map((e) => e.weight) + .reduce((weight1, weight2) => weight1 * weight2); + } + /** * List of vertices with negative weight. * @returns Vertex[] @@ -206,14 +212,6 @@ export class Network { if (!this.is_multigraph && this.hasEdge(args.from, args.to)) return false; // throw { message: ERROR.NOT_MULTIGRAPH }; - if (!this.is_directed) { - const sorted_vertices = [args.from, args.to].sort(); - const unsorted_vertices = [args.from, args.to]; - if (unsorted_vertices[0] !== sorted_vertices[0]) - args.weight = 1 / args.weight; - [args.from, args.to] = sorted_vertices; - } - this.edges.set(args.id, new Edge(args)); return true; }