Commit 15a53122acf97f9dec5bd77727f2198e7f985590
1 parent
abce2443
Added other simple features
Showing
1 changed file
with
84 additions
and
2 deletions
Show diff stats
stim/biomodels/network.h
... | ... | @@ -138,6 +138,56 @@ public: |
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | + // Returns number of branch points in thenetwork | |
142 | + | |
143 | + unsigned int BranchP(){ | |
144 | + unsigned int B=0; | |
145 | + unsigned int c; | |
146 | + for(unsigned v=0; v < V.size(); v ++){ | |
147 | + c = ((V[v].e[0].size()) + (V[v].e[1].size())); | |
148 | + if (c > 2){ | |
149 | + B += 1;} | |
150 | + } | |
151 | + return B; | |
152 | + | |
153 | + } | |
154 | + | |
155 | + // Returns number of end points (tips) in thenetwork | |
156 | + | |
157 | + unsigned int EndP(){ | |
158 | + unsigned int B=0; | |
159 | + unsigned int c; | |
160 | + for(unsigned v=0; v < V.size(); v ++){ | |
161 | + c = ((V[v].e[0].size()) + (V[v].e[1].size())); | |
162 | + if (c == 1){ | |
163 | + B += 1;} | |
164 | + } | |
165 | + return B; | |
166 | + | |
167 | + } | |
168 | + | |
169 | + //// Returns a dictionary with the key as the vertex | |
170 | + //std::map<std::vector<vertex>,unsigned int> DegreeDict(){ | |
171 | + // std::map<std::vector<vertex>,unsigned int> dd; | |
172 | + // unsigned int c = 0; | |
173 | + // for(unsigned v=0; v < V.size(); v ++){ | |
174 | + // c = ((V[v].e[0].size()) + (V[v].e[1].size())); | |
175 | + // dd[V[v]] = c; | |
176 | + // } | |
177 | + // return dd; | |
178 | + //} | |
179 | + | |
180 | + //// Return number of branching stems | |
181 | + //unsigned int Stems(){ | |
182 | + // unsigned int s = 0; | |
183 | + // std::map<std::vector<vertex>,unsigned int> dd; | |
184 | + // dd = DegreeDict(); | |
185 | + // //for(unsigned v=0; v < V.size(); v ++){ | |
186 | + // // V[v].e[0]. | |
187 | + // return s; | |
188 | + //} | |
189 | + | |
190 | + | |
141 | 191 | // Returns an average of fiber/edge lengths in the network |
142 | 192 | double Lengths(){ |
143 | 193 | stim::vec<T> L;double sumLength = 0; |
... | ... | @@ -171,7 +221,39 @@ public: |
171 | 221 | return avg; |
172 | 222 | } |
173 | 223 | |
224 | + // Returns average contraction of the network | |
225 | + double Contractions(){ | |
226 | + stim::vec<T> t; | |
227 | + stim::vec<T> id1, id2; // starting and ending vertices of the edge | |
228 | + double distance;double contraction;double sumContraction = 0; | |
229 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | |
230 | + id1 = E[e][0]; //get the edge starting point | |
231 | + id2 = E[e][E[e].size() - 1]; //get the edge ending point | |
232 | + distance = (id1 - id2).len(); //displacement between the starting and ending points | |
233 | + contraction = distance / E[e].length(); // tortuoisty = edge length / edge displacement | |
234 | + t.push_back(contraction); | |
235 | + sumContraction += contraction; | |
236 | + } | |
237 | + double avg = sumContraction / E.size(); | |
238 | + return avg; | |
239 | + } | |
174 | 240 | |
241 | + // returns average fractal dimension of the branches of the network | |
242 | + double FractalDimensions(){ | |
243 | + stim::vec<T> t; | |
244 | + stim::vec<T> id1, id2; // starting and ending vertices of the edge | |
245 | + double distance;double fract;double sumFractDim = 0; | |
246 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | |
247 | + id1 = E[e][0]; //get the edge starting point | |
248 | + id2 = E[e][E[e].size() - 1]; //get the edge ending point | |
249 | + distance = (id1 - id2).len(); //displacement between the starting and ending points | |
250 | + fract = std::log(distance) / std::log(E[e].length()); // tortuoisty = edge length / edge displacement | |
251 | + t.push_back(sumFractDim); | |
252 | + sumFractDim += fract; | |
253 | + } | |
254 | + double avg = sumFractDim / E.size(); | |
255 | + return avg; | |
256 | + } | |
175 | 257 | stim::cylinder<T> get_cylinder(unsigned f){ |
176 | 258 | return E[f]; //return the specified edge (casting it to a fiber) |
177 | 259 | } |
... | ... | @@ -206,7 +288,6 @@ public: |
206 | 288 | |
207 | 289 | //find out if the nodes for this fiber have already been created |
208 | 290 | it = find(id2vert.begin(), id2vert.end(), i[0]); //look for the first node |
209 | - it_idx = std::distance(id2vert.begin(), it); | |
210 | 291 | if(it == id2vert.end()){ //if i[0] hasn't already been used |
211 | 292 | vertex new_vertex = new_edge[0]; //create a new vertex, assign it a position |
212 | 293 | new_vertex.e[0].push_back(E.size()); //add the current edge as outgoing |
... | ... | @@ -215,12 +296,12 @@ public: |
215 | 296 | id2vert.push_back(i[0]); //add the ID to the ID->vertex conversion list |
216 | 297 | } |
217 | 298 | else{ //if the vertex already exists |
299 | + it_idx = std::distance(id2vert.begin(), it); | |
218 | 300 | V[it_idx].e[0].push_back(E.size()); //add the current edge as outgoing |
219 | 301 | new_edge.v[0] = it_idx; |
220 | 302 | } |
221 | 303 | |
222 | 304 | it = find(id2vert.begin(), id2vert.end(), i[1]); //look for the second ID |
223 | - it_idx = std::distance(id2vert.begin(), it); | |
224 | 305 | if(it == id2vert.end()){ //if i[1] hasn't already been used |
225 | 306 | vertex new_vertex = new_edge[I-1]; //create a new vertex, assign it a position |
226 | 307 | new_vertex.e[1].push_back(E.size()); //add the current edge as incoming |
... | ... | @@ -229,6 +310,7 @@ public: |
229 | 310 | id2vert.push_back(i[1]); //add the ID to the ID->vertex conversion list |
230 | 311 | } |
231 | 312 | else{ //if the vertex already exists |
313 | + it_idx = std::distance(id2vert.begin(), it); | |
232 | 314 | V[it_idx].e[1].push_back(E.size()); //add the current edge as incoming |
233 | 315 | new_edge.v[1] = it_idx; |
234 | 316 | } | ... | ... |