I have an array of self defined type, called links
, which its elements are of type Link
.
type Link
first::Int64
second::Int64
value::Array{Float64,1}
end
, and moreover for links
, the typeof(links)
is a Vector{Link}
.
As you might have guessed, this is part of a graph definition that I have, which includes edges, and first
refers to one endpoint and second
refers to another endpoint. What I want to do is to select the value
of a link
in links
where the the endpoint first
is equal to a specific node number, let's call it vertex_id
.
so in short I want the following:
value of all those in links, whose .first == vertex_id
.
P.S, I know that for DataFrames of regular types, I can say
df[df[:col1] .== x,:col2]
But is there a similar way to do this for array of a self defined type?
I realized that I can do comprehensions:
[x.value for x in links if x.first == vertex_id]