GithubHelp home page GithubHelp logo

juliagraphs / graphio.jl Goto Github PK

View Code? Open in Web Editor NEW
59.0 5.0 26.0 365 KB

Graph IO functionality for various formats.

License: Other

Julia 100.00%
graphs lightgraphs persistence save load read write julia graph juliagraphs

graphio.jl's Introduction

GraphIO

Build Status codecov.io Code Style: Blue Aqua QA

GraphIO provides support to Graphs.jl for reading/writing graphs in various formats.

Currently, the following functionality is provided:

Format Read Write Multiple Graphs Format Name Comment
EdgeList EdgeListFormat a simple list of sources and dests separated by whitespace and/or comma, one pair per line.
GML GMLFormat
Graph6 Graph6Format
GraphML GraphMLFormat
Pajek NET NETFormat
GEXF GEXFFormat
DOT DOTFormat
CDF CDFFormat

Graphs are read using either the loadgraph function or, for formats that support multiple graphs in a single file, the loadgraphs functions. loadgraph returns a Graph object, while loadgraphs returns a dictionary of Graph objects.

For example, an edgelist file could be loaded as:

graph = loadgraph("path_to_graph/my_edgelist.txt", "graph_key", EdgeListFormat())

Reading different graph types

All *Format types are readily accessible. However, in order to use some of them with loadgraph, additional packages are required. You may thus need to install and load the following dependencies before using parts of GraphIO.jl:

  • Reading DOT or GML files: do using ParserCombinator
  • Reading GEXF or GraphML files: do using EzXML
  • Reading GML files: do using CodecZlib

The current design avoids populating your environment with unnecessary dependencies.

IMPLEMENTATION NOTE: The current design uses package extensions, introduced in Julia v1.9. At the moment, package extensions cannot conditionally load types, that is one of the main reasons why all *Format types are readily accessible. However, the functionality of loadgraph is extended for the various types only when the appropriate dependencies are available. We are searching for more intuitive ways to design this interface.

graphio.jl's People

Contributors

abhinavmehndiratta avatar andreasnoack avatar bicycle1885 avatar dourouc05 avatar filchristou avatar gdalle avatar johnnychen94 avatar matbesancon avatar sbromberger avatar simonschoelly avatar storopoli avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

graphio.jl's Issues

General Graph representations

Probably a good idea to have the readme say:

this package will be generic enough to support any in memory graph representation and any on disk format. if you have a graph format you would like supported please open an issue or a PR!

Precompilation error with ParserCombinator

I have the following error when adding GraphIO and ParserCombinator in a brand new Julia session:

Warning: Module GraphIOGMLExt with build ID ffffffff-ffff-ffff-0000-177dba44e6bc is missing from the cache.
│  │ This may mean GraphIOGMLExt [10735248-2040-59e9-9abe-fdd6b710d968] does not support precompilation but is imported by a module that does.
│  └ @ Base loading.jl:1793
│  ┌ Error: Error during loading of extension GraphIOGMLExt of GraphIO, use `Base.retry_load_extensions()` to retry.
...

And a similar error for GraphIODOTExt.

I have not been able to identify where the issue comes from, but I am opening the issue here since the error only happens if I add both packages and the extension is defined here.
However, it doesn't seem to be an error exclusive to this package, so I will open a discourse thread as well.

Not obvious that gname arg should be "digraph" rather than "graph" when loading directed graph

I was trying to read in the manhatten.graphml file here with loadgraph(...) with the second gname argument hidden and got the Graph graph not found error.
But the GraphML file in question has only one graph. Looking at this line (https://github.com/JuliaGraphs/GraphIO.jl/blob/master/src/GraphML/GraphML.jl#L57) it appears that if the graph is directed, then we need to give "digraph" as the second argument to loadgraph

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Add write function for dot-graphs

Right know, GraphIO can only read dot-graphs. It would be good if we also could write these. The we could use the GraphViz for plotting. While the dot-format has a lot of different features, it would be sufficient for know if we can write graphs of type SimpleGraphand SimpleDiGraph. This should not be very difficult to implement.

Errors to read gml/graphml files

I'm using Julia 0.6.2 with updated packages.
I tried to read gml/graphml files from internet zoo topologies but both types have reading errors as follow:

For gml file http://www.topology-zoo.org/files/AttMpls.gml

g_gml = loadgraph("AttMpls.gml", "graph_key", GMLFormat())
WARNING: consume is now deprecated. Use Channels for inter-task communication.
Stacktrace:
[1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
[2] consume(::Task) at ./deprecated.jl:955
[3] once at ~/.julia/v0.6/ParserCombinator/src/core/parsers.jl:182 [inlined]
[4] (::ParserCombinator.##single_result#36#38{Array{Any,1},UnionAll})(::Array{Any,1}, ::Function, ::String, ::ParserCombinator.Trace) at ~/.julia/v0.6/ParserCombinator/src/core/parsers.jl:193
[5] (::ParserCombinator.#kw##single_result#37)(::Array{Any,1}, ::ParserCombinator.#single_result#37, ::String, ::ParserCombinator.Trace) at ./:0
[6] #parse_raw#6(::Bool, ::Function, ::String) at ~/.julia/v0.6/ParserCombinator/src/gml/GML.jl:87
[7] (::ParserCombinator.Parsers.GML.#kw##parse_raw)(::Array{Any,1}, ::ParserCombinator.Parsers.GML.#parse_raw, ::String) at ./:0
[8] loadgml(::IOStream, ::String) at ~/.julia/v0.6/GraphIO/src/gml.jl:21
[9] loadgraph(::IOStream, ::String, ::GraphIO.GMLFormat) at ~/.julia/v0.6/GraphIO/src/gml.jl:83
[10] (::LightGraphs.##125#126{String,GraphIO.GMLFormat})(::IOStream) at ~/.julia/v0.6/LightGraphs/src/persistence/common.jl:15
[11] open(::LightGraphs.##125#126{String,GraphIO.GMLFormat}, ::String, ::String) at ./iostream.jl:152
[12] loadgraph(::String, ::String, ::GraphIO.GMLFormat) at ~/.julia/v0.6/LightGraphs/src/persistence/common.jl:14
[13] eval(::Module, ::Any) at ./boot.jl:235
[14] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
[15] macro expansion at ./REPL.jl:97 [inlined]
[16] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
WARNING: produce is now deprecated. Use Channels for inter-task communication.
Stacktrace:
[1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
[2] produce(::Array{Any,1}) at ./deprecated.jl:909
[3] #producer#27(::Bool, ::Function, ::ParserCombinator.NoCache{String,Int64}, ::ParserCombinator.Trace) at ~/.julia/v0.6/ParserCombinator/src/core/parsers.jl:141
[4] (::ParserCombinator.#kw##producer)(::Array{Any,1}, ::ParserCombinator.#producer, ::ParserCombinator.NoCache{String,Int64}, ::ParserCombinator.Trace) at ./:0
[5] (::ParserCombinator.##29#30{Bool,ParserCombinator.Trace,ParserCombinator.NoCache{String,Int64}})() at ~/.julia/v0.6/ParserCombinator/src/core/parsers.jl:171
while loading no file, in expression starting on line 0
ERROR: Graph graph_key not found
Stacktrace:
[1] loadgml(::IOStream, ::String) at ~/.julia/v0.6/GraphIO/src/gml.jl:28
[2] loadgraph(::IOStream, ::String, ::GraphIO.GMLFormat) at ~/.julia/v0.6/GraphIO/src/gml.jl:83
[3] (::LightGraphs.##125#126{String,GraphIO.GMLFormat})(::IOStream) at ~/.julia/v0.6/LightGraphs/src/persistence/common.jl:15
[4] open(::LightGraphs.##125#126{String,GraphIO.GMLFormat}, ::String, ::String) at ./iostream.jl:152
[5] loadgraph(::String, ::String, ::GraphIO.GMLFormat) at ~/.julia/v0.6/LightGraphs/src/persistence/common.jl:14

For graphml file http://www.topology-zoo.org/files/AttMpls.graphml

g_graphml = loadgraph("AttMpls.graphml", "graph_key", GraphMLFormat())
WARNING: Skipping unknown XML element 'key' - further warnings will be suppressed
ERROR: Graph graph_key not found
Stacktrace:
[1] loadgraphml(::IOStream, ::String) at ~/.julia/v0.6/GraphIO/src/graphml.jl:58
[2] loadgraph(::IOStream, ::String, ::GraphIO.GraphMLFormat) at ~/.julia/v0.6/GraphIO/src/graphml.jl:122
[3] (::LightGraphs.##125#126{String,GraphIO.GraphMLFormat})(::IOStream) at ~/.julia/v0.6/LightGraphs/src/persistence/common.jl:15
[4] open(::LightGraphs.##125#126{String,GraphIO.GraphMLFormat}, ::String, ::String) at ./iostream.jl:152
[5] loadgraph(::String, ::String, ::GraphIO.GraphMLFormat) at ~/.julia/v0.6/LightGraphs/src/persistence/common.jl:14

Missing concrete examples on how to get a graph from each file format

I migrated this year from Python to Julia and after working for 7 years with python igraph and networkx, yesterday I started testing LightGraphs.jl and GraphIO.jl. I've been searching the web more than 1 hour to find out how to read a graph from a GML file. Unfortunately there is no documentation for GraphIO :(

?GML.loadgml
No documentation found.

GraphIO.GML.loadgml is a Function.

# 1 method for generic function "loadgml":
[1] loadgml(io::IO, gname::String) in GraphIO.GML at ....path to GML.jl

I couldn't find any (working) example on julia discourse or SO. To be more precise, I want to load and parse this gml file: https://github.com/empet/Datasets/blob/master/gstrang_descendants.gml.
with the following code (suggested by deprecation.jl):

using LightGraphs
using ParserCombinator               
using GraphIO: GML
f = open("gstrang_descendants.gml")
GML.loadgml(f, "graph")

What string should be passed as gname? I also tried "digraph" but got the same error:

KeyError: key :graph not found

Please give at least in the README file an example to see concretely how we can define a graph loaded from each file format.

Warning for GMLFormat

When using GMLFormat, the following warning is given.

┌ Warning: `GraphIO.GMLFormat`  has been moved to submodule `GraphIO.GML` and needs `ParserCombinator.jl` to be imported first. I.e. use
│     using ParserCombinator
│     GraphIO.GML.GMLFormat()
│   caller = searchall(::NWNGSearchConfig, ::String) at SearchWeakly.jl:333
└ @ SearchWeakly ~/Dropbox/Research/2020/Lena/SearchWeakly/src/SearchWeakly.jl:333

However, if you try

import ParserCombinator
using GraphIO: GML

you will see GML is not defined.

supporting attributes for GraphML formats

I would like to be able to read a metagraph from a graphML format.
This means reading in all attributes and properties that a graphML file may contain, and storing them in a metagraph.
I 've been playing around for the last hours with the package and I got it going.

Obviously the packet dependencies will grow (MetaGraphs)

The implementation is done using XPath and DOM and not the EzXML.StreamReader for the reason that there needs to be some memory on the parser in order to remember whose are the properties read.
I don't argue that it is impossible to do with EzXML.StreamReader and I also understand that reading all structure in RAM is more resource-hungry.
I just implemented the obvious solution

Is it fine if I do a PR ?

loadgraph as undirected

At the moment, loadgraph creates a Directed Graph. A useful feature could be to have an argument to create an Undirected Graph?

loadgraph not loading gml file

Hello guys, Im trying to load a gml file, but I got some issues:

using LightGraphs, ParserCombinator, GraphIO graph = loadgraph("output.gml", "digraph", GraphIO.GML.GMLFormat())

When I execute the source code I always get the following message: ERROR: LoadError: UndefVarError: loadgraph not defined

DIMACS format

DIMACS (or, rather, some extension of the official DIMACS) seems to be a fairly standard graph specification format. I especially see it for lists of graphs for computational challenge problems such as clique finding or chromatic number. Is this format supported by GraphIO.jl? If not, should I add it and submit a pull request?

There are examples and a description of the format here: https://mat.tepper.cmu.edu/COLOR02/

The format has a header starting with "p" that tells the number of vertices and edges, then lines starting with "e" giving the edges. Lines starting with "c" are comments, and there can be other data which could be ignored by a basic reader.

c Lines starting with "c" are comments
p edge 125 736
e 5 1
...

UndefVarError: DOT not defined

I'm trying to test basic functionality and I got stuck here:

julia> using LightGraphs, GraphIO

julia> graph = loadgraph("gr.dot", "gr", DOTFormat())
ERROR: UndefVarError: DOT not defined
Stacktrace:
 [1] DOTFormat() at /home/paul/.julia/packages/GraphIO/IgxnP/src/deprecations.jl:29
 [2] top-level scope at REPL[3]:1
 [3] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088

I'm using Julia 1.5.1 on Ubuntu 18.04.

ERROR: UndefVarError: GraphML not defined while saving a graph

I am trying to save a graph in GraphML format and get an error:

julia> using LightGraphs, GraphIO

julia> g = SimpleGraph(5, 7)
{5, 7} undirected simple Int64 graph

julia> savegraph("graph", g, "simplegraph", GraphMLFormat())
ERROR: UndefVarError: GraphML not defined
Stacktrace:
 [1] GraphMLFormat() at C:\Users\alexa\.julia\packages\GraphIO\IgxnP\src\deprecations.jl:19
 [2] top-level scope at REPL[3]:1
 [3] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088

Any ideas why? Other formats work fine.

Reading DOT files incorrectly

Hello!

(First my apologies for asking the question here; I didn't know how to reach out otherwise.)

I read the DOT tests in graphio.jl to try to understand the usage of loadgraph(), but following the code there doesn't seem to work. Here's what I did:

GraphIO.loadgraph("1.dot", "kkk", GraphIO.DOTFormat())
ERROR: Graph kkk not found
Stacktrace:
 [1] loaddot(::GZip.GZipStream, ::String) at /Users/zhao/.julia/v0.6/GraphIO/src/dot.jl:30
 [2] gzopen(::LightGraphs.##109#110{String,GraphIO.DOTFormat}, ::String, ::String) at /Users/zhao/.julia/v0.6/GZip/src/GZip.jl:268
 [3] loadgraph(::String, ::String, ::GraphIO.DOTFormat) at /Users/zhao/.julia/v0.6/LightGraphs/src/persistence/common.jl:14

I'm a bit thrown off by the second input parameter; what does gname mean? Do you need to create the graph by calling LightGraphs constructor beforehand and hence storing the DOT file there, or the LightGraphs object will be created automatically by calling loadgraph()? Any example of loadgraph() will be appreciated. Thanks!

Not sure if mis-using or bug: ERROR: InexactError()

Trouble loading graphml. File has vertex attributes, which may be cause of problem?

julia> f = open("/users/nick/desktop/anon_voz6_sms18_0.75_months.graphml", "r")
IOStream(<file /users/nick/desktop/anon_voz6_sms18_0.75_months.graphml>)

julia> g = loadgraph(f, "graph", GraphMLFormat())
ERROR: InexactError()
Stacktrace:
 [1] macro expansion at /Users/Nick/.julia/v0.6/EzXML/src/error.jl:50 [inlined]
 [2] parsexml(::String) at /Users/Nick/.julia/v0.6/EzXML/src/document.jl:91
 [3] loadgraphml(::IOStream, ::String) at /Users/Nick/.julia/v0.6/GraphIO/src/graphml.jl:30
 [4] loadgraph(::IOStream, ::String, ::GraphIO.GraphMLFormat) at /Users/Nick/.julia/v0.6/GraphIO/src/graphml.jl:114

ParserCombinator v2.1.0 breaks GraphIO's DOTFormat parsing

When using ParserCombinator v2.0.0, parsing a simple DOT file seems to work fine. Parsing the same file with ParserCombinator v2.1.0 throws an exception. Here is my test.jl file:

import Pkg

tmpdir = mktempdir()

redirect_stderr(devnull) do
  Pkg.activate(mktempdir())
  Pkg.add("LightGraphs")
  Pkg.add("GraphIO")
  Pkg.add(name="ParserCombinator", version=ARGS[1])
end

Pkg.status()

using ParserCombinator, GraphIO, LightGraphs

testdot = joinpath(tmpdir, "test.dot")

open(testdot, "w") do f
  println(f, "graph G { a -- b }")
end

@show loadgraphs(testdot, GraphIO.DOT.DOTFormat())

Here's what I get with ParserCombinator v2.0.0:

$ julia test.jl v2.0.0
      Status `/private/var/folders/r7/cttx9fdj2t705nst90989_440000gn/T/jl_OG4Ypk/Project.toml`
  [aa1b3936] GraphIO v0.5.0
  [093fc24a] LightGraphs v1.3.5
  [fae87a5f] ParserCombinator v2.0.0
loadgraphs(testdot, GraphIO.DOT.DOTFormat()) = Dict{String, AbstractGraph}("G" => {2, 1} undirected simple Int64 graph)

Here is what I get with ParserCombinator v2.1.0:

$ julia test.jl v2.1.0
      Status `/private/var/folders/r7/cttx9fdj2t705nst90989_440000gn/T/jl_eIECUl/Project.toml`
  [aa1b3936] GraphIO v0.5.0
  [093fc24a] LightGraphs v1.3.5
  [fae87a5f] ParserCombinator v2.1.0
ERROR: LoadError: MethodError: no method matching get(::ParserCombinator.Parsers.DOT.StringID, ::ParserCombinator.Parsers.DOT.StringID)
Closest candidates are:
  get(::DataStructures.DefaultOrderedDict, ::Any...) at /Users/davidm/.julia/packages/DataStructures/nBjdy/src/delegate.jl:21
  get(::DataStructures.SwissDict{K, V}, ::Any, ::Any) where {K, V} at /Users/davidm/.julia/packages/DataStructures/nBjdy/src/swiss_dict.jl:490
  get(::Test.GenericDict, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1663
  ...
Stacktrace:
 [1] loaddot_mult(io::IOStream)
   @ GraphIO.DOT ~/.julia/packages/GraphIO/IgxnP/src/DOT/Dot.jl:80
 [2] loadgraphs
   @ ~/.julia/packages/GraphIO/IgxnP/src/DOT/Dot.jl:87 [inlined]
 [3] #119
   @ ~/.julia/packages/LightGraphs/IgJif/src/persistence/common.jl:35 [inlined]
 [4] open(::LightGraphs.var"#119#120"{GraphIO.DOT.DOTFormat}, ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Base ./io.jl:330
 [5] open
   @ ./io.jl:328 [inlined]
 [6] loadgraphs(fn::String, format::GraphIO.DOT.DOTFormat)
   @ LightGraphs ~/.julia/packages/LightGraphs/IgJif/src/persistence/common.jl:34
 [7] top-level scope
   @ show.jl:955
in expression starting at /Users/davidm/local/src/test.jl:22

GML Format and meta data

Hi!

I'm working on a project whereby I'm loading a GML file which includes node meta data, roughly in the following format;

node
  [
    id 0
    type "Person"
    age "67"
    gender "Female"
  ]

I've adapted the function _gml_read_one_graph(gs, dir) function to return a MetaGraph object which has the properties from the GML file stored as properties with the vertices. Would an implementation be of interest for GraphIO.jl (or MetaGraphs.jl)?

GraphIOGraphMLExt does not support precompilation but is imported by a module that does.

I upgraded to Julia 1.9.3 and now I can't get GraphIO to work. I am getting an error that says:

│ This may mean GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9] does not support precompilation but is imported by a module that does.

Error:
julia> graph = loadgraph("/home/shared/graph1.gml", GraphIO.GraphML.GraphMLFormat())
ERROR: MethodError: no method matching loadgraph(::IOStream, ::String, ::GraphIO.GraphML.GraphMLFormat)

Closest candidates are:
loadgraph(::AbstractString, ::AbstractString, ::Graphs.AbstractGraphFormat)
@ Graphs ~/.julia/packages/Graphs/FXxqo/src/persistence/common.jl:13
loadgraph(::IO, ::String, ::LGFormat)
@ Graphs ~/.julia/packages/Graphs/FXxqo/src/persistence/lg.jl:146
loadgraph(::IO, ::String, ::GraphIO.NET.NETFormat)
@ GraphIO ~/.julia/packages/GraphIO/lObxj/src/NET/Net.jl:75
...

Stacktrace:
[1] (::Graphs.var"#148#149"{String, GraphIO.GraphML.GraphMLFormat})(io::IOStream)
@ Graphs ~/.julia/packages/Graphs/FXxqo/src/persistence/common.jl:15
[2] open(::Graphs.var"#148#149"{String, GraphIO.GraphML.GraphMLFormat}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base ./io.jl:395
[3] open(::Function, ::String, ::String)
@ Base ./io.jl:392
[4] loadgraph(fn::String, gname::String, format::GraphIO.GraphML.GraphMLFormat)
@ Graphs ~/.julia/packages/Graphs/FXxqo/src/persistence/common.jl:14
[5] loadgraph(fn::String, format::GraphIO.GraphML.GraphMLFormat)
@ Graphs ~/.julia/packages/Graphs/FXxqo/src/persistence/common.jl:20
[6] top-level scope
@ REPL[8]:1

julia> using EzXML
│ Package EzXML not found, but a package named EzXML is available from a registry.
│ Install package?
│ (@v1.9) pkg> add EzXML
└ (y/n/o) [y]: y
Resolving package versions...
Installed EzXML ─ v1.1.0
Updating ~/.julia/environments/v1.9/Project.toml
[8f5d6c58] + EzXML v1.1.0
Updating ~/.julia/environments/v1.9/Manifest.toml
[8f5d6c58] + EzXML v1.1.0
Precompiling project...
3 dependencies successfully precompiled in 3 seconds. 138 already precompiled.
2 dependencies had warnings during precompilation:
┌ GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9]
│ ┌ Warning: Module GraphIOGraphMLExt with build ID ffffffff-ffff-ffff-0000-6336445ddfed is missing from the cache.
│ │ This may mean GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9] does not support precompilation but is imported by a module that does.
│ └ @ Base loading.jl:1793
│ ┌ Error: Error during loading of extension GraphIOGraphMLExt of GraphIO, use Base.retry_load_extensions() to retry.
│ │ exception =
│ │ 1-element ExceptionStack:
│ │ Declaring precompile(false) is not allowed in files that are being precompiled.
│ │ Stacktrace:
│ │ [1] _require(pkg::Base.PkgId, env::Nothing)
│ │ @ Base ./loading.jl:1797
│ │ [2] _require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│ │ @ Base ./loading.jl:1660
│ │ [3] _require_prelocked(uuidkey::Base.PkgId)
│ │ @ Base ./loading.jl:1658
│ │ [4] run_extension_callbacks(extid::Base.ExtensionId)
│ │ @ Base ./loading.jl:1255
│ │ [5] run_extension_callbacks(pkgid::Base.PkgId)
│ │ @ Base ./loading.jl:1290
│ │ [6] run_package_callbacks(modkey::Base.PkgId)
│ │ @ Base ./loading.jl:1124
│ │ [7] _require_prelocked(uuidkey::Base.PkgId, env::String)
│ │ @ Base ./loading.jl:1667
│ │ [8] macro expansion
│ │ @ ./loading.jl:1648 [inlined]
│ │ [9] macro expansion
│ │ @ ./lock.jl:267 [inlined]
│ │ [10] require(into::Module, mod::Symbol)
│ │ @ Base ./loading.jl:1611
│ │ [11] top-level scope
│ │ @ ~/.julia/packages/GraphIO/lObxj/ext/GraphIOGEXFExt.jl:8
│ │ [12] include
│ │ @ ./Base.jl:457 [inlined]
│ │ [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
│ │ @ Base ./loading.jl:2049
│ │ [14] top-level scope
│ │ @ stdin:3
│ │ [15] eval
│ │ @ ./boot.jl:370 [inlined]
│ │ [16] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│ │ @ Base ./loading.jl:1903
│ │ [17] include_string
│ │ @ ./loading.jl:1913 [inlined]
│ │ [18] exec_options(opts::Base.JLOptions)
│ │ @ Base ./client.jl:305
│ │ [19] _start()
│ │ @ Base ./client.jl:522
│ └ @ Base loading.jl:1261

┌ GraphIOGEXFExt [2b66b2ab-f48c-58da-9972-304391d605c5]
│ ┌ Warning: Module GraphIOGEXFExt with build ID ffffffff-ffff-ffff-0000-633643bc417c is missing from the cache.
│ │ This may mean GraphIOGEXFExt [2b66b2ab-f48c-58da-9972-304391d605c5] does not support precompilation but is imported by a module that does.
│ └ @ Base loading.jl:1793
│ ┌ Error: Error during loading of extension GraphIOGEXFExt of GraphIO, use Base.retry_load_extensions() to retry.
│ │ exception =
│ │ 1-element ExceptionStack:
│ │ Declaring precompile(false) is not allowed in files that are being precompiled.
│ │ Stacktrace:
│ │ [1] _require(pkg::Base.PkgId, env::Nothing)
│ │ @ Base ./loading.jl:1797
│ │ [2] _require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│ │ @ Base ./loading.jl:1660
│ │ [3] _require_prelocked(uuidkey::Base.PkgId)
│ │ @ Base ./loading.jl:1658
│ │ [4] run_extension_callbacks(extid::Base.ExtensionId)
│ │ @ Base ./loading.jl:1255
│ │ [5] run_extension_callbacks(pkgid::Base.PkgId)
│ │ @ Base ./loading.jl:1290
│ │ [6] run_package_callbacks(modkey::Base.PkgId)
│ │ @ Base ./loading.jl:1124
│ │ [7] _require_prelocked(uuidkey::Base.PkgId, env::String)
│ │ @ Base ./loading.jl:1667
│ │ [8] macro expansion
│ │ @ ./loading.jl:1648 [inlined]
│ │ [9] macro expansion
│ │ @ ./lock.jl:267 [inlined]
│ │ [10] require(into::Module, mod::Symbol)
│ │ @ Base ./loading.jl:1611
│ │ [11] top-level scope
│ │ @ ~/.julia/packages/GraphIO/lObxj/ext/GraphIOGraphMLExt.jl:8
│ │ [12] include
│ │ @ ./Base.jl:457 [inlined]
│ │ [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
│ │ @ Base ./loading.jl:2049
│ │ [14] top-level scope
│ │ @ stdin:3
│ │ [15] eval
│ │ @ ./boot.jl:370 [inlined]
│ │ [16] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│ │ @ Base ./loading.jl:1903
│ │ [17] include_string
│ │ @ ./loading.jl:1913 [inlined]
│ │ [18] exec_options(opts::Base.JLOptions)
│ │ @ Base ./client.jl:305
│ │ [19] _start()
│ │ @ Base ./client.jl:522
│ └ @ Base loading.jl:1261

[ Info: Precompiling GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9]
┌ Warning: Module GraphIOGraphMLExt with build ID ffffffff-ffff-ffff-0000-6336d9bff1e8 is missing from the cache.
│ This may mean GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9] does not support precompilation but is imported by a module that does.
└ @ Base loading.jl:1793
┌ Error: Error during loading of extension GraphIOGraphMLExt of GraphIO, use Base.retry_load_extensions() to retry.
│ exception =
│ 1-element ExceptionStack:
│ Declaring precompile(false) is not allowed in files that are being precompiled.
│ Stacktrace:
│ [1] _require(pkg::Base.PkgId, env::Nothing)
│ @ Base ./loading.jl:1797
│ [2] _require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│ @ Base ./loading.jl:1660
│ [3] _require_prelocked(uuidkey::Base.PkgId)
│ @ Base ./loading.jl:1658
│ [4] run_extension_callbacks(extid::Base.ExtensionId)
│ @ Base ./loading.jl:1255
│ [5] run_extension_callbacks(pkgid::Base.PkgId)
│ @ Base ./loading.jl:1290
│ [6] run_package_callbacks(modkey::Base.PkgId)
│ @ Base ./loading.jl:1124
│ [7] _require_prelocked(uuidkey::Base.PkgId, env::String)
│ @ Base ./loading.jl:1667
│ [8] macro expansion
│ @ ./loading.jl:1648 [inlined]
│ [9] macro expansion
│ @ ./lock.jl:267 [inlined]
│ [10] require(into::Module, mod::Symbol)
│ @ Base ./loading.jl:1611
│ [11] top-level scope
│ @ ~/.julia/packages/GraphIO/lObxj/ext/GraphIOGEXFExt.jl:8
│ [12] include
│ @ ./Base.jl:457 [inlined]
│ [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
│ @ Base ./loading.jl:2049
│ [14] top-level scope
│ @ stdin:3
│ [15] eval
│ @ ./boot.jl:370 [inlined]
│ [16] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│ @ Base ./loading.jl:1903
│ [17] include_string
│ @ ./loading.jl:1913 [inlined]
│ [18] exec_options(opts::Base.JLOptions)
│ @ Base ./client.jl:305
│ [19] _start()
│ @ Base ./client.jl:522
└ @ Base loading.jl:1261

Support mmap'ed edge lists

Sometimes you want to build a graph from an edgelist file, but don't have 2X memory lying around. So you should mmap the edgelist and then build the graph. Here is a sample implementation.

using Base.Mmap
using Base.Test
using LightGraphs

function elmmap{T}(io::IO, t::T, ne::Integer)
    el = Base.Mmap.mmap(io, Array{Int,2}, (n,2))
    return el
end


function elgraph(el::Array{Int,2}, maxv)
    g = Graph(maxv)
    for i in 1:size(el,1)
        src, dst = el[i,1], el[i,2]
        if src > nv(g) || dst > nv(g)
            add_vertex!(g, maximum(src,dst) - nv(g))
        end
        add_edge!(g, src, dst)
    end
    return g
end


n = 100
write("tmp.bin", [1:n 2*(1:n)])
fp = elmmap(open("tmp.bin", "r"), Int, n)
@test fp == [1:n 2*(1:n)]
g = elgraph(fp, 2n)

Error during loading of extension GraphIOGraphMLExt of GraphIO

During installation, I encountered the following error:

┌ GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9]
│  ┌ Warning: Module GraphIOGraphMLExt with build ID ffffffff-ffff-ffff-0000-942c1aa21206 is missing from the cache.
│  │ This may mean GraphIOGraphMLExt [357b67ce-33f7-597c-8dc9-7304118606a9] does not support precompilation but is imported by a module that does.
│  └ @ Base loading.jl:1793
│  ┌ Error: Error during loading of extension GraphIOGraphMLExt of GraphIO, use `Base.retry_load_extensions()` to retry.
│  │   exception =
│  │    1-element ExceptionStack:
│  │    Declaring __precompile__(false) is not allowed in files that are being precompiled.
│  │    Stacktrace:
│  │      [1] _require(pkg::Base.PkgId, env::Nothing)
│  │        @ Base ./loading.jl:1797
│  │      [2] _require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│  │        @ Base ./loading.jl:1660
│  │      [3] _require_prelocked(uuidkey::Base.PkgId)
│  │        @ Base ./loading.jl:1658
│  │      [4] run_extension_callbacks(extid::Base.ExtensionId)
│  │        @ Base ./loading.jl:1255
│  │      [5] run_extension_callbacks(pkgid::Base.PkgId)
│  │        @ Base ./loading.jl:1290
│  │      [6] run_package_callbacks(modkey::Base.PkgId)
│  │        @ Base ./loading.jl:1124
│  │      [7] _require_prelocked(uuidkey::Base.PkgId, env::String)
│  │        @ Base ./loading.jl:1667
│  │      [8] macro expansion
│  │        @ ./loading.jl:1648 [inlined]
│  │      [9] macro expansion
│  │        @ ./lock.jl:267 [inlined]
│  │     [10] require(into::Module, mod::Symbol)
│  │        @ Base ./loading.jl:1611
│  │     [11] top-level scope
│  │        @ ~/.local/share/julia/packages/GraphIO/lObxj/ext/GraphIOGEXFExt.jl:8
│  │     [12] include
│  │        @ ./Base.jl:457 [inlined]
│  │     [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
│  │        @ Base ./loading.jl:2045
│  │     [14] top-level scope
│  │        @ stdin:3
│  │     [15] eval
│  │        @ ./boot.jl:370 [inlined]
│  │     [16] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│  │        @ Base ./loading.jl:1899
│  │     [17] include_string
│  │        @ ./loading.jl:1909 [inlined]
│  │     [18] exec_options(opts::Base.JLOptions)
│  │        @ Base ./client.jl:305
│  │     [19] _start()
│  │        @ Base ./client.jl:522
│  └ @ Base loading.jl:1261
└  
┌ GraphIOGEXFExt [2b66b2ab-f48c-58da-9972-304391d605c5]
│  ┌ Warning: Module GraphIOGEXFExt with build ID ffffffff-ffff-ffff-0000-942c1e2baaf3 is missing from the cache.
│  │ This may mean GraphIOGEXFExt [2b66b2ab-f48c-58da-9972-304391d605c5] does not support precompilation but is imported by a module that does.
│  └ @ Base loading.jl:1793
│  ┌ Error: Error during loading of extension GraphIOGEXFExt of GraphIO, use `Base.retry_load_extensions()` to retry.
│  │   exception =
│  │    1-element ExceptionStack:
│  │    Declaring __precompile__(false) is not allowed in files that are being precompiled.
│  │    Stacktrace:
│  │      [1] _require(pkg::Base.PkgId, env::Nothing)
│  │        @ Base ./loading.jl:1797
│  │      [2] _require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│  │        @ Base ./loading.jl:1660
│  │      [3] _require_prelocked(uuidkey::Base.PkgId)
│  │        @ Base ./loading.jl:1658
│  │      [4] run_extension_callbacks(extid::Base.ExtensionId)
│  │        @ Base ./loading.jl:1255
│  │      [5] run_extension_callbacks(pkgid::Base.PkgId)
│  │        @ Base ./loading.jl:1290
│  │      [6] run_package_callbacks(modkey::Base.PkgId)
│  │        @ Base ./loading.jl:1124
│  │      [7] _require_prelocked(uuidkey::Base.PkgId, env::String)
│  │        @ Base ./loading.jl:1667
│  │      [8] macro expansion
│  │        @ ./loading.jl:1648 [inlined]
│  │      [9] macro expansion
│  │        @ ./lock.jl:267 [inlined]
│  │     [10] require(into::Module, mod::Symbol)
│  │        @ Base ./loading.jl:1611
│  │     [11] top-level scope
│  │        @ ~/.local/share/julia/packages/GraphIO/lObxj/ext/GraphIOGraphMLExt.jl:8
│  │     [12] include
│  │        @ ./Base.jl:457 [inlined]
│  │     [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
│  │        @ Base ./loading.jl:2045
│  │     [14] top-level scope
│  │        @ stdin:3
│  │     [15] eval
│  │        @ ./boot.jl:370 [inlined]
│  │     [16] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
│  │        @ Base ./loading.jl:1899
│  │     [17] include_string
│  │        @ ./loading.jl:1909 [inlined]
│  │     [18] exec_options(opts::Base.JLOptions)
│  │        @ Base ./client.jl:305
│  │     [19] _start()
│  │        @ Base ./client.jl:522
│  └ @ Base loading.jl:1261
└  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.