# Writing simple weighted digraphs

**URL:** <https://discourse.julialang.org/t/writing-simple-weighted-digraphs/36263>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 20, 2020, 2:37pm UTC](https://discourse.julialang.org/t/writing-simple-weighted-digraphs/36263 "2020-03-20T14:37:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eaubanel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eaubanel/32/13327_2.png) [@eaubanel](https://discourse.julialang.org/u/eaubanel)\
**Post date:** [March 20, 2020, 2:37pm UTC](https://discourse.julialang.org/t/writing-simple-weighted-digraphs/36263/1 "2020-03-20T14:37:57Z")

</div>

I’m using the LightGraphs package and I’m trying to write a simple weighted digraph to a file:

```julia
julia> g
{32768, 467633} directed simple Int64 graph with Float64 weights
julia> savegraph("testwt.lg",g)
1
julia> gl=loadgraph("testwt.lg")
ERROR: ArgumentError: invalid base 10 digit 'g' in "graph"

```

> **Stack trace**
>
> ```julia
> Stacktrace:
> [1] tryparse_internal(::Type{Int64}, ::SubString{String}, ::Int64, ::Int64, ::Int64, ::Bool) at ./parse.jl:132
> [2] #parse#347(::Nothing, ::typeof(parse), ::Type{Int64}, ::SubString{String}) at ./parse.jl:238
> [3] parse at ./parse.jl:238 [inlined]
> [4] _parse_header(::SubString{String}) at /Users/eaubanel/.julia/packages/LightGraphs/UPjU9/src/persistence/lg.jl:65
> [5] loadlg(::IOStream, ::String) at /Users/eaubanel/.julia/packages/LightGraphs/UPjU9/src/persistence/lg.jl:104
> [6] loadgraph at /Users/eaubanel/.julia/packages/LightGraphs/UPjU9/src/persistence/lg.jl:147 [inlined]
> [7] #117 at /Users/eaubanel/.julia/packages/LightGraphs/UPjU9/src/persistence/common.jl:15 [inlined]
> [8] #open#271(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(open), ::LightGraphs.var"#117#118"{String,LGFormat}, ::String, ::Vararg{String,N} where N) at ./io.jl:298
> [9] open at ./io.jl:296 [inlined]
> [10] loadgraph at /Users/eaubanel/.julia/packages/LightGraphs/UPjU9/src/persistence/common.jl:14 [inlined]
> [11] loadgraph(::String) at /Users/eaubanel/.julia/packages/LightGraphs/UPjU9/src/persistence/common.jl:18
> [12] top-level scope at none:0
> 
> ```

What am I doing wrong? Reading and writing this way works fine for unweighted digraphs.
