{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaGraphs/LightGraphs.jl/issues/268","labels_url":"https://api.github.com/repos/JuliaGraphs/LightGraphs.jl/issues/268/labels{/name}","comments_url":"https://api.github.com/repos/JuliaGraphs/LightGraphs.jl/issues/268/comments","events_url":"https://api.github.com/repos/JuliaGraphs/LightGraphs.jl/issues/268/events","html_url":"https://github.com/JuliaGraphs/LightGraphs.jl/issues/268","id":124202178,"number":268,"title":"Dynamic Network Analysis - Subgraphs without 0-degree vertices","user":{"login":"chameau13","id":9676803,"avatar_url":"https://avatars.githubusercontent.com/u/9676803?v=3","gravatar_id":"","url":"https://api.github.com/users/chameau13","html_url":"https://github.com/chameau13","followers_url":"https://api.github.com/users/chameau13/followers","following_url":"https://api.github.com/users/chameau13/following{/other_user}","gists_url":"https://api.github.com/users/chameau13/gists{/gist_id}","starred_url":"https://api.github.com/users/chameau13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chameau13/subscriptions","organizations_url":"https://api.github.com/users/chameau13/orgs","repos_url":"https://api.github.com/users/chameau13/repos","events_url":"https://api.github.com/users/chameau13/events{/privacy}","received_events_url":"https://api.github.com/users/chameau13/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-12-29T12:07:11Z","updated_at":"2016-01-06T01:49:56Z","closed_at":null,"body":"Hi,\r\n\r\nFirst of all, thank you for this great piece of software. Coming from R I was frustrated by the weak performance and I am delighted by the possibilities Julia and LightGraph offer for social network analysis. In this conversion process I am however also encountering a few problems. This is why I am addressing myself to you. \r\n\r\nI am trying to use LG to analyze a graph of which the edges were created at different time points, in a dynamic manner. I therefore wrote the following function:\r\n\r\n```Julia \r\nfunction netstat(windows,time,elist, numv)\r\ntdf = elist[(time - Dates.Day(windows)) .<= elist[:date] .<= time, [:Source,:Target]];\r\ng   = DiGraph(numv);\r\n\r\nfor row in eachrow(tdf)\r\n    add_edge!(g, row[:Source],row[:Target])\r\nend\r\n@show (windows, time)\r\nhcat([time for i=1:nv(g)],g.vertices,[windows for i=1:nv(g)],degree_centrality(g),pagerank(g),closeness_centrality(g),local_clustering_coefficient(g),\r\nkatz_centrality(g));\r\nend\r\n```\r\nHere **elist** is a DataFrame with the edge list, where each edge contains a timestamp, **numv** is the number of vertices, **windows** is the respective time window which is used and  **time** is the timestamp which serves to iterate through the edge list. \r\n\r\nThe problem is now the specification of **numv**. I would like to get the centrality measures of each vertex each at each time point it is observed. There are around 9500 vertices in my edge list and the number of edges is, depending on the window size, between 200 and 3000 per time period. The way `DiGraph()` works (or as I understood it) however forces me to always have a graph with 9500 vertices, although most of them don't even appear at given time period with a given window size (this means there are a lot of 0-degree vertices). I think this slows down my computations tremendously. Of course I could always recode the vertex ids in the edge list, compute the stats, and then recode them again before saving, but this seems a bit cumbersome to me. Is there an easier way to do this?\r\n\r\nI found the subgraph functionality but it seems also not to do what I want:\r\n```Julia \r\ng   = DiGraph(5)\r\nsg = g[[2,4]]\r\nadd_edge!(sg,2,4)\r\n```     \r\nThe code above yields \"ERROR: Vertex 4 not in graph\". I actually understood this functionality in this context as to keep only vertices 2 and 4 in the graph. But it seems the vertex numbering is not preserved. It only reduces the number of vertices to two, however with IDs 1 and 2. \r\n\r\nI grateful for every comment!\r\n\r\nBest,\r\n\r\nAndreas\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaGraphs/LightGraphs.jl/issues/comments/169193012","html_url":"https://github.com/JuliaGraphs/LightGraphs.jl/issues/268#issuecomment-169193012","issue_url":"https://api.github.com/repos/JuliaGraphs/LightGraphs.jl/issues/268","id":169193012,"user":{"login":"chameau13","id":9676803,"avatar_url":"https://avatars.githubusercontent.com/u/9676803?v=3","gravatar_id":"","url":"https://api.github.com/users/chameau13","html_url":"https://github.com/chameau13","followers_url":"https://api.github.com/users/chameau13/followers","following_url":"https://api.github.com/users/chameau13/following{/other_user}","gists_url":"https://api.github.com/users/chameau13/gists{/gist_id}","starred_url":"https://api.github.com/users/chameau13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chameau13/subscriptions","organizations_url":"https://api.github.com/users/chameau13/orgs","repos_url":"https://api.github.com/users/chameau13/repos","events_url":"https://api.github.com/users/chameau13/events{/privacy}","received_events_url":"https://api.github.com/users/chameau13/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T01:49:56Z","updated_at":"2016-01-06T01:49:56Z","body":"Hi, if you are interested, I am going to post my solution tomorrow when I am back in the office. "}}