Skip to content

Commit 0005d14

Browse files
authored
Merge pull request #22 from emfeltham/master
Generalize type for `df`?
2 parents 6817bd1 + 137364e commit 0005d14

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/GraphDataFrameBridge.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import MetaGraphs.MetaDiGraph
99

1010

1111
function MetaGraph(
12-
df::DataFrame,
12+
df::T,
1313
origin::Symbol,
1414
destination::Symbol;
1515
weight::Symbol = Symbol(),
1616
edge_attributes::Union{Vector{Symbol},Symbol} = Vector{Symbol}(),
1717
vertex_attributes::DataFrame = DataFrame(),
18-
vertex_id_col::Symbol = Symbol())
18+
vertex_id_col::Symbol = Symbol()
19+
) where T <: AbstractDataFrame
1920

2021
"""
2122
MetaGraph(df, origin, destination)
@@ -53,13 +54,14 @@ end
5354

5455

5556
function MetaDiGraph(
56-
df::DataFrame,
57+
df::T,
5758
origin::Symbol,
5859
destination::Symbol;
5960
weight::Symbol = Symbol(),
6061
edge_attributes::Union{Vector{Symbol},Symbol} = Vector{Symbol}(),
6162
vertex_attributes::DataFrame = DataFrame(),
62-
vertex_id_col::Symbol = Symbol())
63+
vertex_id_col::Symbol = Symbol()
64+
) where T <: AbstractDataFrame
6365

6466
"""
6567
MetaDiGraph(df, origin, destination)
@@ -96,13 +98,14 @@ end
9698

9799

98100
function metagraph_from_dataframe(graph_type,
99-
df::DataFrame,
101+
df::T,
100102
origin::Symbol,
101103
destination::Symbol,
102104
weight::Symbol = Symbol(),
103105
edge_attributes::Union{Vector{Symbol},Symbol} = Vector{Symbol}(),
104106
vertex_attributes::DataFrame = DataFrame(),
105-
vertex_id_col::Symbol = Symbol())
107+
vertex_id_col::Symbol = Symbol()
108+
) where T <: AbstractDataFrame
106109

107110
# Map node names to vertex IDs
108111
nodes = sort!(unique!([df[:, origin]; df[:, destination]]))

0 commit comments

Comments
 (0)