> > Then you can use the methods described at > http://graphsjl-docs.readthedocs.org/en/latest/graphs.html#graph > <http://www.google.com/url?q=http%3A%2F%2Fgraphsjl-docs.readthedocs.org%2Fen%2Flatest%2Fgraphs.html%23graph&sa=D&sntz=1&usg=AFQjCNHVoi5mCb8OfzJ8seHEQEjoCuoN9Q> > to > extract/operate on edges and vertices and so on.
Any ideas how to extract a certain vertex/edge by its index other than extract all vertices/edges by vertices()/edges() and check the index? The latter approach takes O(n) time. On Sunday, June 1, 2014 10:30:41 PM UTC+8, Alex wrote: > > Hi Paulo, > > you can get your graph as follows > julia> using Graphs > > julia> g = simple_graph(4) > Directed Graph (4 vertices, 0 edges) > > julia> add_edge!(g, 1, 2) > edge [1]: 1 -- 2 > > julia> add_edge!(g, 2, 4) > edge [2]: 2 -- 4 > > julia> add_edge!(g, 4, 3) > edge [3]: 4 -- 3 > > julia> add_edge!(g, 3, 1) > edge [4]: 3 -- 1 > > julia> add_edge!(g, 1, 4) > edge [5]: 1 -- 4 > > julia> add_edge!(g, 3, 2) > edge [6]: 3 -- 2 > > julia> g > Directed Graph (4 vertices, 6 edges) > > Then you can use the methods described at > http://graphsjl-docs.readthedocs.org/en/latest/graphs.html#graph to > extract/operate on edges and vertices and so on. > > Hope that helps, > > Alex. > > On Sunday, 1 June 2014 16:17:02 UTC+2, Paulo Castro wrote: >> >> Hi guys, >> >> Sorry about making this kind of question, but even after reading the >> documentation, I don't know how to create the simplest graph object using >> Graphs.jl. For example, I want to create the following graph: >> >> >> <http://i.stack.imgur.com/820Fl.png> >> >> Can someone give me the directions to start? >> >
