# Creating a Weighted Graph

**URL:** https://discourse.julialang.org/t/creating-a-weighted-graph/41241
**Category:** Graphs
**Tags:** lightgraphs, graphs
**Created:** [June 12, 2020, 3:44am UTC](https://discourse.julialang.org/t/creating-a-weighted-graph/41241 "2020-06-12T03:44:10Z")
**Posts on this page:** 1
**Showing post:** 23

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [June 13, 2020, 6:38pm UTC](https://discourse.julialang.org/t/creating-a-weighted-graph/41241/23 "2020-06-13T18:38:45Z")

</div>

> [@anon94023334](#):
>
> Please don’t access internal fields of any JuliaGraphs structs. We can’t prevent it because there’s no such thing as access control in Julia, but it’s undefined behavior and your code is pretty much guaranteed to break on you at some point without warning if you do this.

I just wanna point two things:

1. [You (kinda) can have private fields in Julia if you really want.](https://discourse.julialang.org/t/private-properties-in-julia-0-7/10785/5)
2. Undefined behavior is a term often used by a language specification for code that should not be written because the language definition does not specify what to do in such case and, consequently, each compiler implementation can act differently, possibly with segmentation fault or silently corrupting data. Accessing such fields is probably not undefined behavior, with a specific version of Julia (language, not compiler implementation) and a specific version of the package in question (with source code available), it will behave in a predictably fashion, what is problematic is that you violated the package API and any version change can break the code (because the implementation detail you are accessing can change with minor changes), but if you know what you are doing and have no problem with fixing the package version, it can be a solution (while very restrictive).

---

_[View the full topic](https://discourse.julialang.org/t/creating-a-weighted-graph/41241)._
