diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index 02a42e2..2e6917e 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -138,6 +138,56 @@ public: } + // Returns number of branch points in thenetwork + + unsigned int BranchP(){ + unsigned int B=0; + unsigned int c; + for(unsigned v=0; v < V.size(); v ++){ + c = ((V[v].e[0].size()) + (V[v].e[1].size())); + if (c > 2){ + B += 1;} + } + return B; + + } + + // Returns number of end points (tips) in thenetwork + + unsigned int EndP(){ + unsigned int B=0; + unsigned int c; + for(unsigned v=0; v < V.size(); v ++){ + c = ((V[v].e[0].size()) + (V[v].e[1].size())); + if (c == 1){ + B += 1;} + } + return B; + + } + + //// Returns a dictionary with the key as the vertex + //std::map,unsigned int> DegreeDict(){ + // std::map,unsigned int> dd; + // unsigned int c = 0; + // for(unsigned v=0; v < V.size(); v ++){ + // c = ((V[v].e[0].size()) + (V[v].e[1].size())); + // dd[V[v]] = c; + // } + // return dd; + //} + + //// Return number of branching stems + //unsigned int Stems(){ + // unsigned int s = 0; + // std::map,unsigned int> dd; + // dd = DegreeDict(); + // //for(unsigned v=0; v < V.size(); v ++){ + // // V[v].e[0]. + // return s; + //} + + // Returns an average of fiber/edge lengths in the network double Lengths(){ stim::vec L;double sumLength = 0; @@ -171,7 +221,39 @@ public: return avg; } + // Returns average contraction of the network + double Contractions(){ + stim::vec t; + stim::vec id1, id2; // starting and ending vertices of the edge + double distance;double contraction;double sumContraction = 0; + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network + id1 = E[e][0]; //get the edge starting point + id2 = E[e][E[e].size() - 1]; //get the edge ending point + distance = (id1 - id2).len(); //displacement between the starting and ending points + contraction = distance / E[e].length(); // tortuoisty = edge length / edge displacement + t.push_back(contraction); + sumContraction += contraction; + } + double avg = sumContraction / E.size(); + return avg; + } + // returns average fractal dimension of the branches of the network + double FractalDimensions(){ + stim::vec t; + stim::vec id1, id2; // starting and ending vertices of the edge + double distance;double fract;double sumFractDim = 0; + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network + id1 = E[e][0]; //get the edge starting point + id2 = E[e][E[e].size() - 1]; //get the edge ending point + distance = (id1 - id2).len(); //displacement between the starting and ending points + fract = std::log(distance) / std::log(E[e].length()); // tortuoisty = edge length / edge displacement + t.push_back(sumFractDim); + sumFractDim += fract; + } + double avg = sumFractDim / E.size(); + return avg; + } stim::cylinder get_cylinder(unsigned f){ return E[f]; //return the specified edge (casting it to a fiber) } @@ -206,7 +288,6 @@ public: //find out if the nodes for this fiber have already been created it = find(id2vert.begin(), id2vert.end(), i[0]); //look for the first node - it_idx = std::distance(id2vert.begin(), it); if(it == id2vert.end()){ //if i[0] hasn't already been used vertex new_vertex = new_edge[0]; //create a new vertex, assign it a position new_vertex.e[0].push_back(E.size()); //add the current edge as outgoing @@ -215,12 +296,12 @@ public: id2vert.push_back(i[0]); //add the ID to the ID->vertex conversion list } else{ //if the vertex already exists + it_idx = std::distance(id2vert.begin(), it); V[it_idx].e[0].push_back(E.size()); //add the current edge as outgoing new_edge.v[0] = it_idx; } it = find(id2vert.begin(), id2vert.end(), i[1]); //look for the second ID - it_idx = std::distance(id2vert.begin(), it); if(it == id2vert.end()){ //if i[1] hasn't already been used vertex new_vertex = new_edge[I-1]; //create a new vertex, assign it a position new_vertex.e[1].push_back(E.size()); //add the current edge as incoming @@ -229,6 +310,7 @@ public: id2vert.push_back(i[1]); //add the ID to the ID->vertex conversion list } else{ //if the vertex already exists + it_idx = std::distance(id2vert.begin(), it); V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming new_edge.v[1] = it_idx; } -- libgit2 0.21.4