Added test

This commit is contained in:
Tim committed 2023-11-10 18:56:51 +01:00
1 parent 41af7e2d18
commit 410b690873
18 files changed
+619 -384

No files matched your search

@@ -1,272 +1,272 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<script src="lib/bindings/utils.js"></script> <script src="lib/bindings/utils.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<center> <center>
<h1></h1> <h1></h1>
</center> </center>
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" /> <!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>--> <script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<link <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
rel="stylesheet" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous" crossorigin="anonymous"
/> />
<script <script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous" crossorigin="anonymous"
></script> ></script>
<center> <center>
<h1></h1> <h1></h1>
</center> </center>
<style type="text/css"> <style type="text/css">
#mynetwork { #mynetwork {
width: 100%; width: 100%;
height: 600px; height: 600px;
background-color: white; background-color: white;
border: 1px solid lightgray; border: 1px solid lightgray;
position: relative; position: relative;
float: left; float: left;
} }
#loadingBar { #loadingBar {
position:absolute; position:absolute;
top:0px; top:0px;
left:0px; left:0px;
width: 100%; width: 100%;
height: 600px; height: 600px;
background-color:rgba(200,200,200,0.8); background-color:rgba(200,200,200,0.8);
-webkit-transition: all 0.5s ease; -webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease; -moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease; -ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease; -o-transition: all 0.5s ease;
transition: all 0.5s ease; transition: all 0.5s ease;
opacity:1; opacity:1;
} }
#bar { #bar {
position:absolute; position:absolute;
top:0px; top:0px;
left:0px; left:0px;
width:20px; width:20px;
height:20px; height:20px;
margin:auto auto auto auto; margin:auto auto auto auto;
border-radius:11px; border-radius:11px;
border:2px solid rgba(30,30,30,0.05); border:2px solid rgba(30,30,30,0.05);
background: rgb(0, 173, 246); /* Old browsers */ background: rgb(0, 173, 246); /* Old browsers */
box-shadow: 2px 0px 4px rgba(0,0,0,0.4); box-shadow: 2px 0px 4px rgba(0,0,0,0.4);
} }
#border { #border {
position:absolute; position:absolute;
top:10px; top:10px;
left:10px; left:10px;
width:500px; width:500px;
height:23px; height:23px;
margin:auto auto auto auto; margin:auto auto auto auto;
box-shadow: 0px 0px 4px rgba(0,0,0,0.2); box-shadow: 0px 0px 4px rgba(0,0,0,0.2);
border-radius:10px; border-radius:10px;
} }
#text { #text {
position:absolute; position:absolute;
top:8px; top:8px;
left:530px; left:530px;
width:30px; width:30px;
height:50px; height:50px;
margin:auto auto auto auto; margin:auto auto auto auto;
font-size:22px; font-size:22px;
color: #000000; color: #000000;
} }
div.outerBorder { div.outerBorder {
position:relative; position:relative;
top:400px; top:400px;
width:600px; width:600px;
height:44px; height:44px;
margin:auto auto auto auto; margin:auto auto auto auto;
border:8px solid rgba(0,0,0,0.1); border:8px solid rgba(0,0,0,0.1);
background: rgb(252,252,252); /* Old browsers */ background: rgb(252,252,252); /* Old browsers */
background: -moz-linear-gradient(top, rgba(252,252,252,1) 0%, rgba(237,237,237,1) 100%); /* FF3.6+ */ background: -moz-linear-gradient(top, rgba(252,252,252,1) 0%, rgba(237,237,237,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(252,252,252,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(252,252,252,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */ background: -webkit-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */ background: -o-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* IE10+ */ background: -ms-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* W3C */ background: linear-gradient(to bottom, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */
border-radius:72px; border-radius:72px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2); box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
} }
#config { #config {
float: left; float: left;
width: 400px; width: 400px;
height: 600px; height: 600px;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="card" style="width: 100%"> <div class="card" style="width: 100%">
<div id="mynetwork" class="card-body"></div> <div id="mynetwork" class="card-body"></div>
</div> </div>
<div id="loadingBar"> <div id="loadingBar">
<div class="outerBorder"> <div class="outerBorder">
<div id="text">0%</div> <div id="text">0%</div>
<div id="border"> <div id="border">
<div id="bar"></div> <div id="bar"></div>
</div> </div>
</div> </div>
</div> </div>
<div id="config"></div> <div id="config"></div>
<script type="text/javascript"> <script type="text/javascript">
// initialize global variables. // initialize global variables.
var edges; var edges;
var nodes; var nodes;
var allNodes; var allNodes;
var allEdges; var allEdges;
var nodeColors; var nodeColors;
var originalNodes; var originalNodes;
var network; var network;
var container; var container;
var options, data; var options, data;
var filter = { var filter = {
item : '', item : '',
property : '', property : '',
value : [] value : []
}; };
// This method is responsible for drawing the graph, returns the drawn network // This method is responsible for drawing the graph, returns the drawn network
function drawGraph() { function drawGraph() {
var container = document.getElementById('mynetwork'); var container = document.getElementById('mynetwork');
// parsing and collecting nodes and edges from the python // parsing and collecting nodes and edges from the python
nodes = new vis.DataSet([{"color": "blue", "font": {"color": "black"}, "id": "person_1", "label": "Nicolas, Tetau", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_1", "label": "0 10 24 Telefondienste GmbH", "shape": "dot", "size": 10, "type": "Company"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_4", "label": "01050.com GmbH", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_2", "label": "Lutz, Dammast", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_3", "label": "Rosemarie, Tutsch", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_2", "label": "1. Staiger Grundst\u00fccksverwaltung GmbH \u0026 Co. KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_4", "label": "Marc, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_5", "label": "Michaela, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_6", "label": "Margarete, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_7", "label": "Bruno, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_8", "label": "Nicole, Hofmann", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_9", "label": "Steffen, Autenrieth", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_3", "label": "1 A Autenrieth Kunststofftechnik GmbH \u0026 Co. KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_10", "label": "Stefanie, Bischoff", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_2213", "label": "Multi-Center Warenvertriebs GmbH", "shape": "dot", "size": 10, "type": "Company"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_5", "label": "2. Schaper Objekt GmbH \u0026 Co. Kiel KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_11", "label": "Christel, Achilles", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_6", "label": "AASP Filmproduktionsgesellschaft mbH \u0026 Co. Leonie KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_12", "label": "Wilhelm, Ackermann", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_13", "label": "Harald, Ahrens", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_14", "label": "Mohamed Maged, Al Sibai", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_15", "label": "Salim, Al-Bazaz", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_16", "label": "Marina, Attawar", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_17", "label": "Ankica, Babic-Pavicic", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_18", "label": "Ingo, Bak", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_19", "label": "Christoph, Becker", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_20", "label": "Olaf, Becker", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_21", "label": "Rainer, Berg", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_22", "label": "Pieter, Berkhout", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_23", "label": "Bernhard, Berns", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_24", "label": "Franz-Hartwig, Betz", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_25", "label": "Claus, Birken", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_26", "label": "Helmut, Blessing", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_27", "label": "Heinz G., Bohnet", "shape": "doLine truncated nodes = new vis.DataSet([{"color": "blue", "font": {"color": "black"}, "id": "person_1", "label": "Nicolas, Tetau", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_1", "label": "0 10 24 Telefondienste GmbH", "shape": "dot", "size": 10, "type": "Company"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_4", "label": "01050.com GmbH", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_2", "label": "Lutz, Dammast", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_3", "label": "Rosemarie, Tutsch", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_2", "label": "1. Staiger Grundst\u00fccksverwaltung GmbH \u0026 Co. KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_4", "label": "Marc, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_5", "label": "Michaela, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_6", "label": "Margarete, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_7", "label": "Bruno, Staiger", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_8", "label": "Nicole, Hofmann", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_9", "label": "Steffen, Autenrieth", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_3", "label": "1 A Autenrieth Kunststofftechnik GmbH \u0026 Co. KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_10", "label": "Stefanie, Bischoff", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_2213", "label": "Multi-Center Warenvertriebs GmbH", "shape": "dot", "size": 10, "type": "Company"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_5", "label": "2. Schaper Objekt GmbH \u0026 Co. Kiel KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_11", "label": "Christel, Achilles", "shape": "dot", "size": 10, "type": "Person"}, {"color": "#729b79ff", "font": {"color": "black"}, "id": "company_6", "label": "AASP Filmproduktionsgesellschaft mbH \u0026 Co. Leonie KG", "shape": "dot", "size": 10, "type": "Company"}, {"color": "blue", "font": {"color": "black"}, "id": "person_12", "label": "Wilhelm, Ackermann", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_13", "label": "Harald, Ahrens", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_14", "label": "Mohamed Maged, Al Sibai", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_15", "label": "Salim, Al-Bazaz", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_16", "label": "Marina, Attawar", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_17", "label": "Ankica, Babic-Pavicic", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_18", "label": "Ingo, Bak", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_19", "label": "Christoph, Becker", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_20", "label": "Olaf, Becker", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_21", "label": "Rainer, Berg", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_22", "label": "Pieter, Berkhout", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_23", "label": "Bernhard, Berns", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_24", "label": "Franz-Hartwig, Betz", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_25", "label": "Claus, Birken", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_26", "label": "Helmut, Blessing", "shape": "dot", "size": 10, "type": "Person"}, {"color": "blue", "font": {"color": "black"}, "id": "person_27", "label": "Heinz G., Bohnet", "shape": "doLine truncated
edges = new vis.DataSet([{"from": "person_1", "label": "Gesch\u00e4ftsf\u00fchrer(in)", "to": "company_1", "width": 1}, {"from": "person_1", "label": "Gesch\u00e4ftsf\u00fchrer(in)", "to": "company_4", "width": 1}, {"from": "company_1", "label": "Prokurist(in)", "to": "person_2", "width": 1}, {"from": "person_2", "label": "Prokurist(in)", "to": "company_4", "width": 1}, {"from": "person_3", "label": "Kommanditist(in)", "to": "company_2", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_4", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_5", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_6", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_7", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_8", "width": 1}, {"from": "person_9", "label": "Kommanditist(in)", "to": "company_3", "width": 1}, {"from": "company_3", "label": "Prokurist(in)", "to": "person_10", "width": 1}, {"from": "company_2213", "label": "Kommanditist(in)", "to": "company_5", "width": 1}, {"from": "person_11", "label": "Kommanditist(in)", "to": "company_6", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_12", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_13", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_14", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_15", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_16", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_17", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_18", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_19", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_20", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_21", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_22", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_23", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_24", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_25", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_26", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_27", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_28", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_29", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_30", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_31", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_32", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_33", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_34", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_35", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_36", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_37", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_38", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_39", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_40", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_41", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_42", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_43", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_44", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_45", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_46", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_47", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_48", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_49", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_50", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_51", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_52", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_53", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_54", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_55", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_56", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)",Line truncated edges = new vis.DataSet([{"from": "person_1", "label": "Gesch\u00e4ftsf\u00fchrer(in)", "to": "company_1", "width": 1}, {"from": "person_1", "label": "Gesch\u00e4ftsf\u00fchrer(in)", "to": "company_4", "width": 1}, {"from": "company_1", "label": "Prokurist(in)", "to": "person_2", "width": 1}, {"from": "person_2", "label": "Prokurist(in)", "to": "company_4", "width": 1}, {"from": "person_3", "label": "Kommanditist(in)", "to": "company_2", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_4", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_5", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_6", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_7", "width": 1}, {"from": "company_2", "label": "Kommanditist(in)", "to": "person_8", "width": 1}, {"from": "person_9", "label": "Kommanditist(in)", "to": "company_3", "width": 1}, {"from": "company_3", "label": "Prokurist(in)", "to": "person_10", "width": 1}, {"from": "company_2213", "label": "Kommanditist(in)", "to": "company_5", "width": 1}, {"from": "person_11", "label": "Kommanditist(in)", "to": "company_6", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_12", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_13", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_14", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_15", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_16", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_17", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_18", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_19", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_20", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_21", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_22", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_23", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_24", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_25", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_26", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_27", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_28", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_29", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_30", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_31", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_32", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_33", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_34", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_35", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_36", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_37", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_38", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_39", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_40", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_41", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_42", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_43", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_44", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_45", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_46", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_47", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_48", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_49", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_50", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_51", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_52", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_53", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_54", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_55", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)", "to": "person_56", "width": 1}, {"from": "company_6", "label": "Kommanditist(in)",Line truncated
nodeColors = {}; nodeColors = {};
allNodes = nodes.get({ returnType: "Object" }); allNodes = nodes.get({ returnType: "Object" });
for (nodeId in allNodes) { for (nodeId in allNodes) {
nodeColors[nodeId] = allNodes[nodeId].color; nodeColors[nodeId] = allNodes[nodeId].color;
} }
allEdges = edges.get({ returnType: "Object" }); allEdges = edges.get({ returnType: "Object" });
// adding nodes and edges to the graph // adding nodes and edges to the graph
data = {nodes: nodes, edges: edges}; data = {nodes: nodes, edges: edges};
var options = { var options = {
"configure": { "configure": {
"enabled": true "enabled": true
}, },
"edges": { "edges": {
"color": { "color": {
"inherit": false "inherit": false
}, },
"smooth": { "smooth": {
"enabled": true, "enabled": true,
"type": "dynamic" "type": "dynamic"
} }
}, },
"interaction": { "interaction": {
"dragNodes": true, "dragNodes": true,
"hideEdgesOnDrag": false, "hideEdgesOnDrag": false,
"hideNodesOnDrag": false "hideNodesOnDrag": false
}, },
"physics": { "physics": {
"enabled": true, "enabled": true,
"repulsion": { "repulsion": {
"centralGravity": 0.2, "centralGravity": 0.2,
"damping": 0.09, "damping": 0.09,
"nodeDistance": 100, "nodeDistance": 100,
"springConstant": 0.05, "springConstant": 0.05,
"springLength": 200 "springLength": 200
}, },
"solver": "repulsion", "solver": "repulsion",
"stabilization": { "stabilization": {
"enabled": true, "enabled": true,
"fit": true, "fit": true,
"iterations": 1000, "iterations": 1000,
"onlyDynamicEdges": false, "onlyDynamicEdges": false,
"updateInterval": 50 "updateInterval": 50
} }
} }
}; };
// if this network requires displaying the configure window, // if this network requires displaying the configure window,
// put it in its div // put it in its div
options.configure["container"] = document.getElementById("config"); options.configure["container"] = document.getElementById("config");
network = new vis.Network(container, data, options); network = new vis.Network(container, data, options);
network.on("click", neighbourhoodHighlight); network.on("click", neighbourhoodHighlight);
network.on("stabilizationProgress", function(params) { network.on("stabilizationProgress", function(params) {
document.getElementById('loadingBar').removeAttribute("style"); document.getElementById('loadingBar').removeAttribute("style");
var maxWidth = 496; var maxWidth = 496;
var minWidth = 20; var minWidth = 20;
var widthFactor = params.iterations/params.total; var widthFactor = params.iterations/params.total;
var width = Math.max(minWidth,maxWidth * widthFactor); var width = Math.max(minWidth,maxWidth * widthFactor);
document.getElementById('bar').style.width = width + 'px'; document.getElementById('bar').style.width = width + 'px';
document.getElementById('text').innerHTML = Math.round(widthFactor*100) + '%'; document.getElementById('text').innerHTML = Math.round(widthFactor*100) + '%';
}); });
network.once("stabilizationIterationsDone", function() { network.once("stabilizationIterationsDone", function() {
document.getElementById('text').innerHTML = '100%'; document.getElementById('text').innerHTML = '100%';
document.getElementById('bar').style.width = '496px'; document.getElementById('bar').style.width = '496px';
document.getElementById('loadingBar').style.opacity = 0; document.getElementById('loadingBar').style.opacity = 0;
// really clean the dom element // really clean the dom element
setTimeout(function () {document.getElementById('loadingBar').style.display = 'none';}, 500); setTimeout(function () {document.getElementById('loadingBar').style.display = 'none';}, 500);
}); });
return network; return network;
} }
drawGraph(); drawGraph();
</script> </script>
</body> </body>
</html> </html>
@@ -45,11 +45,11 @@ def create_2d_graph( # noqa PLR0913
# pos = nx.planar_layout(graph) # pos = nx.planar_layout(graph)
case "Random": case "Random":
pos = nx.random_layout(graph) pos = nx.random_layout(graph)
case "Shell only 2D)": case "(Shell only 2D)":
pos = nx.shell_layout(graph) pos = nx.shell_layout(graph)
# case "Spectral": # case "Spectral":
# pos = nx.spectral_layout(graph) # pos = nx.spectral_layout(graph)
case "Spiral only 2D)": case "(Spiral only 2D)":
pos = nx.spiral_layout(graph) pos = nx.spiral_layout(graph)
# case "Multipartite": # case "Multipartite":
# pos = nx.multipartite_layout(graph) # pos = nx.multipartite_layout(graph)
@@ -22,20 +22,28 @@ def initialize_network(edges: list, nodes: dict) -> tuple[nx.Graph, pd.DataFrame
# update node attributes from dataframe # update node attributes from dataframe
nx.set_node_attributes(graph, nodes) nx.set_node_attributes(graph, nodes)
# Create a DataFrame with all Metrics
# Create a DataFrame with all Metrics # Create a DataFrame with all Metrics
metrics = pd.DataFrame( metrics = pd.DataFrame(
{ columns=[
"eigenvector": nx.eigenvector_centrality(graph).values(), "eigenvector",
"degree": nx.degree_centrality(graph).values(), "degree",
"betweenness": nx.betweenness_centrality(graph).values(), "betweenness",
"closeness": nx.closeness_centrality(graph).values(), "closeness",
"pagerank": nx.pagerank(graph).values(), "pagerank",
"category": nx.get_node_attributes(graph, "type").values(), "category",
"designation": nx.get_node_attributes(graph, "name").values(), "designation",
"id": nx.get_node_attributes(graph, "id").values(), "id",
} ]
).T )
metrics["eigenvector"] = nx.eigenvector_centrality(graph).values()
metrics["degree"] = nx.degree_centrality(graph).values()
metrics["betweenness"] = nx.betweenness_centrality(graph).values()
metrics["closeness"] = nx.closeness_centrality(graph).values()
metrics["pagerank"] = nx.pagerank(graph).values()
metrics["category"] = nx.get_node_attributes(graph, "type").values()
metrics["designation"] = nx.get_node_attributes(graph, "name").values()
metrics["id"] = nx.get_node_attributes(graph, "id").values()
return graph, metrics return graph, metrics
@@ -64,7 +72,7 @@ def initialize_network_with_reduced_metrics(
# Create a DataFrame with all Metrics # Create a DataFrame with all Metrics
metrics = pd.DataFrame( metrics = pd.DataFrame(
columns=["degree", "eigenvector", "betweenness", "closeness", "pagerank"] columns=["degree", "betweenness", "closeness", "category", "designation", "id"]
) )
# metrics["eigenvector"] = nx.eigenvector_centrality(graph).values() # metrics["eigenvector"] = nx.eigenvector_centrality(graph).values()
metrics["degree"] = nx.degree_centrality(graph).values() metrics["degree"] = nx.degree_centrality(graph).values()
@@ -63,24 +63,6 @@ def find_all_company_relations() -> pd.DataFrame:
return companies_relations_df return companies_relations_df
def find_top_companies() -> pd.DataFrame:
"""_summary_.
Returns:
pd.DataFrame: _description_
"""
session = SessionHandler.session
assert session # noqa: S101
query_companies = session.query(entities.Company) # .all()
companies_df: pd.DataFrame = pd.read_sql(str(query_companies), session.bind) # type: ignore
companies_df = companies_df.head()
companies_df = companies_df[["company_name"]]
companies_df["Platzierung"] = [1, 2, 3, 4, 5]
companies_df["Umsatz M€"] = [1, 2, 3, 4, 5]
return companies_df[["Platzierung", "company_name", "Umsatz M€"]]
def get_all_company_relations() -> pd.DataFrame: def get_all_company_relations() -> pd.DataFrame:
"""This Methods makes a Database Request for all Companies and their relations, modifies the ID Column and returns the Result as an DataFrame. """This Methods makes a Database Request for all Companies and their relations, modifies the ID Column and returns the Result as an DataFrame.
@@ -380,7 +362,7 @@ def create_edge_and_node_list_for_company(
return nodes, edges return nodes, edges
def get_all_metrics_from_id(company_id: int) -> pd.Series: def get_all_metrics_from_id(company_id: str) -> pd.Series:
"""Returns all Metric for the given ID. """Returns all Metric for the given ID.
Args: Args:
-7
View File
@@ -1,7 +0,0 @@
"""Test for the NetworkX Component."""
from aki_prj23_transparenzregister.ui.archive import networkx_dash
def network_graph(edges: None) -> None:
"""Checks if an import co company_stats_dash can be made."""
assert networkx_dash is not None
+67 -14
View File
@@ -2,15 +2,21 @@
import datetime import datetime
from collections.abc import Generator from collections.abc import Generator
import networkx as nx import plotly.graph_objects as go
import pandas as pd
import pytest import pytest
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
from aki_prj23_transparenzregister.utils.networkx import network_2d
from aki_prj23_transparenzregister.utils.networkx.network_2d import create_2d_graph
from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network
def test_import() -> None:
"""Checks if an import co company_stats_dash can be made."""
assert network_2d is not None
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def _set_session(full_db: Session) -> Generator[None, None, None]: def _set_session(full_db: Session) -> Generator[None, None, None]:
"""Sets a session for the dash application to be used.""" """Sets a session for the dash application to be used."""
@@ -19,32 +25,79 @@ def _set_session(full_db: Session) -> Generator[None, None, None]:
SessionHandler.session = None SessionHandler.session = None
def test_initialize_network() -> None: def test_create_2d_graph() -> None:
"""Tests the creation of a 2D Graph."""
edges: list = [ edges: list = [
{"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"}, {"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"}, {"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_1", "to": "c_2", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_53", "to": "c_1", "type": "HAFTENDER_GESELLSCHAFTER"},
] ]
nodes: dict = { nodes: dict = {
"c_53": { "c_53": {
"id": "c_53", "id": "c_53",
"name": "1. Freiburger Solarfonds Beteiligungs-KG", "name": "1. Freiburger Solarfonds Beteiligungs-KG",
"type": "company",
"color": "blue", "color": "blue",
}, },
"p_545": { "p_545": {
"id": "p_545", "id": "p_545",
"firstname": "Jürgen", "name": "Wetzel, Jürgen",
"lastname": "Wetzel", "type": "person",
"date_of_birth": datetime.date(1962, 11, 15), "date_of_birth": datetime.date(1962, 11, 15),
"color": "red", "color": "red",
}, },
"c_1": {
"id": "c_1",
"name": "Musterfirma",
"type": "company",
"color": "blue",
},
"c_2": {
"id": "c_2",
"name": "Firma 1",
"type": "company",
"color": "blue",
},
} }
graph, metrics = initialize_network(edges=edges, nodes=nodes) graph, metrics = initialize_network(edges=edges, nodes=nodes)
assert type(graph) is nx.Graph metric = "None"
assert type(metrics) is pd.DataFrame layout = "Spring"
# assert list(metrics.columns) == [ edge_annotation = False
# "degree", edge_thickness = 1
# "eigenvector", figure = create_2d_graph(
# "betweeness", graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
# "closeness", )
# "pagerank", assert type(figure) is go.Figure
# ]
metric = "degree"
layout = "Circular"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
edge_annotation = True
layout = "Kamada Kawai"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Random"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Shell (only 2D)"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Spiral (only 2D)"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
+55 -14
View File
@@ -1,38 +1,79 @@
"""Test the initialize Network function.""" """Test the initialize Network function."""
import datetime import datetime
import networkx as nx import plotly.graph_objects as go
import pandas as pd
from aki_prj23_transparenzregister.utils.networkx import network_3d
from aki_prj23_transparenzregister.utils.networkx.network_3d import create_3d_graph
from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network
def test_initialize_network() -> None: def test_import() -> None:
"""Checks if an import co company_stats_dash can be made."""
assert network_3d is not None
def test_create_3d_graph() -> None:
"""Tests the creation of a 3D Graph."""
edges: list = [ edges: list = [
{"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"}, {"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"}, {"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_1", "to": "c_2", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_53", "to": "c_1", "type": "HAFTENDER_GESELLSCHAFTER"},
] ]
nodes: dict = { nodes: dict = {
"c_53": { "c_53": {
"id": "c_53", "id": "c_53",
"name": "1. Freiburger Solarfonds Beteiligungs-KG", "name": "1. Freiburger Solarfonds Beteiligungs-KG",
"type": "company",
"color": "blue", "color": "blue",
}, },
"p_545": { "p_545": {
"id": "p_545", "id": "p_545",
"firstname": "Jürgen", "name": "Wetzel, Jürgen",
"lastname": "Wetzel", "type": "person",
"date_of_birth": datetime.date(1962, 11, 15), "date_of_birth": datetime.date(1962, 11, 15),
"color": "red", "color": "red",
}, },
"c_1": {
"id": "c_1",
"name": "Musterfirma",
"type": "company",
"color": "blue",
},
"c_2": {
"id": "c_2",
"name": "Firma 1",
"type": "company",
"color": "blue",
},
} }
graph, metrics = initialize_network(edges=edges, nodes=nodes) graph, metrics = initialize_network(edges=edges, nodes=nodes)
assert type(graph) is nx.Graph metric = "None"
assert type(metrics) is pd.DataFrame layout = "Spring"
# assert list(metrics.columns) == [ edge_annotation = False
# "degree", edge_thickness = 1
# "eigenvector", figure = create_3d_graph(
# "betweeness", graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
# "closeness", )
# "pagerank", assert type(figure) is go.Figure
# ]
metric = "degree"
layout = "Circular"
figure = create_3d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
edge_annotation = True
layout = "Kamada Kawai"
figure = create_3d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Random"
figure = create_3d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
+57 -12
View File
@@ -3,38 +3,83 @@ import datetime
import networkx as nx import networkx as nx
import pandas as pd import pandas as pd
import pytest
from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network from aki_prj23_transparenzregister.utils.networkx import network_base
from aki_prj23_transparenzregister.utils.networkx.network_base import (
initialize_network,
initialize_network_with_reduced_metrics,
initialize_network_without_metrics,
)
def test_import() -> None:
"""Checks if an import co company_stats_dash can be made."""
assert network_base is not None
@pytest.mark.tim()
def test_initialize_network() -> None: def test_initialize_network() -> None:
edges: list = [ edges: list = [
{"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"}, {"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"}, {"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_1", "to": "c_2", "type": "HAFTENDER_GESELLSCHAFTER"},
{"from": "c_53", "to": "c_1", "type": "HAFTENDER_GESELLSCHAFTER"},
] ]
nodes: dict = { nodes: dict = {
"c_53": { "c_53": {
"id": "c_53", "id": "c_53",
"name": "1. Freiburger Solarfonds Beteiligungs-KG", "name": "1. Freiburger Solarfonds Beteiligungs-KG",
"type": "company",
"color": "blue", "color": "blue",
}, },
"p_545": { "p_545": {
"id": "p_545", "id": "p_545",
"firstname": "Jürgen", "name": "Wetzel, Jürgen",
"lastname": "Wetzel", "type": "person",
"date_of_birth": datetime.date(1962, 11, 15), "date_of_birth": datetime.date(1962, 11, 15),
"color": "red", "color": "red",
}, },
"c_1": {
"id": "c_1",
"name": "Musterfirma",
"type": "company",
"color": "blue",
},
"c_2": {
"id": "c_2",
"name": "Firma 1",
"type": "company",
"color": "blur",
},
} }
# print(len(edges))
# print(len(nodes))
graph, metrics = initialize_network(edges=edges, nodes=nodes) graph, metrics = initialize_network(edges=edges, nodes=nodes)
assert isinstance(graph, nx.Graph) assert isinstance(graph, nx.Graph)
assert isinstance(metrics, pd.DataFrame) assert isinstance(metrics, pd.DataFrame)
# assert list(metrics.columns) == [ assert list(metrics.columns) == [
# "degree", "eigenvector",
# "eigenvector", "degree",
# "betweeness", "betweenness",
# "closeness", "closeness",
# "pagerank", "pagerank",
# ] "category",
"designation",
"id",
]
graph_reduced, metrics_reduced = initialize_network_with_reduced_metrics(
edges=edges, nodes=nodes
)
assert isinstance(graph_reduced, nx.Graph)
assert isinstance(metrics_reduced, pd.DataFrame)
assert list(metrics_reduced.columns) == [
"degree",
"betweenness",
"closeness",
"category",
"designation",
"id",
]
graph = initialize_network_without_metrics(edges=edges, nodes=nodes)
assert isinstance(graph_reduced, nx.Graph)
+144 -31
View File
@@ -1,37 +1,150 @@
"""Test the initialize Network function.""" """Test the initialize Network function."""
import datetime from collections.abc import Generator
import networkx as nx
import pandas as pd import pandas as pd
import pytest
from sqlalchemy.orm import Session
from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
from aki_prj23_transparenzregister.utils.networkx import networkx_data
from aki_prj23_transparenzregister.utils.networkx.networkx_data import (
create_edge_and_node_list,
create_edge_and_node_list_for_company,
filter_relation_type,
filter_relation_with_more_than_one_connection,
find_all_company_relations,
find_company_relations,
get_all_company_relations,
get_all_person_relations,
)
def test_initialize_network() -> None: @pytest.fixture(autouse=True)
edges: list = [ def _set_session(full_db: Session) -> Generator[None, None, None]:
{"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"}, """Sets a session for the dash application to be used."""
{"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"}, SessionHandler.session = full_db
] yield
nodes: dict = { SessionHandler.session = None
"c_53": {
"id": "c_53",
"name": "1. Freiburger Solarfonds Beteiligungs-KG", def test_import() -> None:
"color": "blue", """Checks if an import co company_stats_dash can be made."""
}, assert networkx_data is not None
"p_545": {
"id": "p_545",
"name": "Jürgen Wenzel", # def test_initialize_network() -> None:
"date_of_birth": datetime.date(1962, 11, 15), # edges: list = [
"color": "red", # {"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"},
}, # {"from": "c_53", "to": "p_545", "type": "HAFTENDER_GESELLSCHAFTER"},
} # {"from": "c_1", "to": "c_2", "type": "HAFTENDER_GESELLSCHAFTER"},
graph, metrics = initialize_network(edges=edges, nodes=nodes) # {"from": "c_53", "to": "c_1", "type": "HAFTENDER_GESELLSCHAFTER"},
assert type(graph) is nx.Graph # ]
assert type(metrics) is pd.DataFrame # nodes: dict = {
# assert list(metrics.columns) == [ # "c_53": {
# "degree", # "id": "c_53",
# "eigenvector", # "name": "1. Freiburger Solarfonds Beteiligungs-KG",
# "betweeness", # "type": "company",
# "closeness", # "color": "blue",
# "pagerank", # },
# ] # "p_545": {
# "id": "p_545",
# "name": "Wetzel, Jürgen",
# "type": "person",
# "date_of_birth": datetime.date(1962, 11, 15),
# "color": "red",
# },
# "c_1": {
# "id": "c_1",
# "name": "Musterfirma",
# "type": "company",
# "color": "blue",
# },
# "c_2": {
# "id": "c_2",
# "name": "Firma 1",
# "type": "company",
# "color": "blur",
# },
# }
def test_find_all_company_relations() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
company_relations_df = find_all_company_relations()
assert type(company_relations_df) is pd.DataFrame
def test_get_all_company_relations() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
company_relations_df = get_all_company_relations()
assert type(company_relations_df) is pd.DataFrame
def test_get_all_person_relations() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
company_relations_df = get_all_person_relations()
assert type(company_relations_df) is pd.DataFrame
def test_filter_relation_type() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
relation_dataframe = get_all_company_relations()
selected_relation_type = "HAFTENDER_GESELLSCHAFTER"
company_relations_df = filter_relation_type(
relation_dataframe, selected_relation_type
)
assert type(company_relations_df) is pd.DataFrame
def test_filter_relation_with_more_than_one_connection() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
relation_dataframe = get_all_company_relations()
id_column_name_to = "c_1"
id_column_name_from = "c_2"
relations_df = filter_relation_with_more_than_one_connection(
relation_dataframe, id_column_name_to, id_column_name_from
)
assert type(relations_df) is pd.DataFrame
def test_create_edge_and_node_list() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
person_df = get_all_person_relations()
company_df = get_all_company_relations()
nodes, edges = create_edge_and_node_list(person_df, company_df)
assert isinstance(nodes, dict)
assert isinstance(edges, list)
def test_find_company_relations() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
selected_company_id = 1
company_relations_df, person_df = find_company_relations(selected_company_id)
assert type(company_relations_df) is pd.DataFrame
assert type(person_df) is pd.DataFrame
def test_create_edge_and_node_list_for_company() -> None:
"""This Test methods tests if the correct type is returned for the corresponding Function."""
company_relations = get_all_company_relations()
nodes, edges = create_edge_and_node_list_for_company(company_relations)
assert isinstance(nodes, dict)
assert isinstance(edges, list)
# @pytest.mark.tim()
# def test_get_all_metrics_from_id() -> None:
# """This Test methods tests if the correct type is returned for the corresponding Function."""
# company_id = 2549
# metrics = get_all_metrics_from_id(company_id)
# assert type(metrics) is pd.Series
# @pytest.mark.tim()
# def test_get_relations_number_from_id() -> None:
# """This Test methods tests if the correct type and number of relations is received."""
# # id = "c_2549"
# id = "c_2667"
# relations_lvl_1, relations_lvl_2, relations_lvl_3 = get_relations_number_from_id(id)
# assert type(relations_lvl_1) is int
# assert type(relations_lvl_2) is int
# assert type(relations_lvl_3) is int