-
Notifications
You must be signed in to change notification settings - Fork 4
Creating Graphs
Ed Scheinerman edited this page Sep 19, 2018
·
14 revisions
Create a new graph with G = SimpleGraph()
. The vertices of this graph may be any Julia type. More likely,
a user will use G = SimpleGraph{T}()
in which vertices are of type T
. Two special cases are provided:
-
IntGraph()
is equivalent toSimpleGraph{Int}()
. One may also haveG = IntGraph(n)
which will create a graph whose vertex set is{1,2,...,n}
(with no edges). -
StringGraph()
is equivalent toSimpleGraph{String}()
.
-
add!(G,v)
adds a vertexv
to the graph. -
add!(G,v,w)
adds the edge(v,w)
to the graph. -
delete!(G,v)
deletes vertexv
from the graph. -
delete!(G,v,w)
deletes the edge(v,w)
from the graph.
If A
is an n
-by-n
symmetric, zero-one, hollow matrix, then SimpleGraph(A)
creates a graph whose vertex
set is {1,2,...,n}
and whose adjacency matrix is A
.