## root / latex / note_w10.tex @ 4f432e4a

History | View | Annotate | Download (1.75 KB)

1 |
%!TEX root = note.tex |
---|---|

2 | |

3 |
%%%%%%%%%%%%%%%%%% |

4 |
% WEEK 10 |

5 |
%%%%%%%%%%%%%%%%%% |

6 |
\section{Week 10} |

7 |
\subsection{Relative Betweenness Centrality} |

8 |
\subsubsection{Problem: listS vs vecS} |

9 |
The original code from the BGL is not working for the Graph with \lstinline{VertexList} set as \lstinline{listS}. The original code works fine for \lstinline{setS}. Below is the original code: |

10 | |

11 |
\begin{lstlisting} |

12 |
template<typename Graph, typename CentralityMap> |

13 |
void |

14 |
relative_betweenness_centrality(const Graph& g, CentralityMap centrality) |

15 |
{ |

16 |
typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator; |

17 |
typedef typename property_traits<CentralityMap>::value_type centrality_type; |

18 | |

19 |
typename graph_traits<Graph>::vertices_size_type n = num_vertices(g); |

20 |
centrality_type factor = centrality_type(2)/centrality_type(n*n - 3*n + 2); |

21 |
vertex_iterator v, v_end; |

22 |
for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { |

23 |
put(centrality, *v, factor * get(centrality, *v)); |

24 |
} |

25 |
} |

26 |
\end{lstlisting} |

27 | |

28 |
\subsubsection{Solution 1} |

29 |
Modify the \lstinline{relative_betweenness_centrality()} to also include the \lstinline{VertexIndexMap} |

30 | |

31 |
This is the most simplified version, where I set the same value for centrality, just to test whether the \lstinline{relative_betweenness_centrality} is working correctly with the \lstinline{VertexIndexMap v_index}. |

32 | |

33 | |

34 |
\subsection{Comparison between networkx and BGL} |

35 |
Both libraries gave the same result. |

36 | |

37 |
\subsubsection{Plotting with gnuplot} |

38 | |

39 |
\textbf{Gnuplot generating upside down plots} |

40 | |

41 |
Check out |

42 |
\href{https://github.com/Marquezino/qwalk/issues/3}{Solution} |

43 | |

44 |
\begin{lstlisting} |

45 |
# Change from |

46 |
set term postscript enhanced color |

47 | |

48 |
# To |

49 |
set terminal postscript eps |

50 |
\end{lstlisting} |

51 | |

52 |