#Set up our dynamic library
useDynLib(network, .registration = TRUE)

#Import some required symbols
import(utils)

importFrom("grDevices", "colors", "gray")
importFrom("graphics", "locator", "par", "plot", "polygon", "rect",
             "strheight", "strwidth", "text")
importFrom("stats", "rnorm")

#Export everything except symbols that start with '.' or end with '_R'.
#exportPattern("^[^\\.].*[^_][^R]$")

# the %c% operator may have already been defined by the sna library if loaded first
# but we can't figure out a way to conditionally export it
export("%c%")

# explicity export only a subset of functions
export(
add.edge,
add.edge.network,
add.edges,
add.edges.network,
add.vertices,
add.vertices.network,
as.color,
as.matrix.network,
as.matrix.network.adjacency,
as.matrix.network.edgelist,
as.matrix.network.incidence,
as.network,
as.network.default,
as.network.matrix,
as.network.network,
as.sociomatrix,
as.edgelist,
as.edgelist.network,
as.edgelist.matrix,
is.edgelist,
"%c%.network",
delete.edge.attribute,
delete.edges,
delete.network.attribute,
delete.vertex.attribute,
delete.vertices,
"%e%",
"%e%<-",
"%eattr%",
"%eattr%<-",
get.edge.attribute,
get.edgeIDs,
get.dyads.eids,
get.edges,
get.edge.value,
get.inducedSubgraph,
get.neighborhood,
get.network.attribute,
get.vertex.attribute,
has.loops,
is.adjacent,
is.bipartite,
is.color,
is.directed,
is.discrete,
is.discrete.character,
is.discrete.numeric,
is.hyper,
is.multiplex,
is.na.network,
is.network,
has.edges,
list.edge.attributes,
list.network.attributes,
list.vertex.attributes,
mixingmatrix,
"%n%",
"%n%<-",
"%nattr%",
"%nattr%<-",
network,
"<-.network",
"|.network",
"-.network",
"!.network",
"[<-.network",
"[.network",
"*.network",
"&.network",
"+.network",
network.adjacency,
network.arrow,
network.bipartite,
network.copy,
network.density,
network.dyadcount,
network.edgecount,
network.edgelabel,
network.edgelist,
network.incidence,
network.initialize,
network.layout.circle,
network.layout.fruchtermanreingold,
network.layout.kamadakawai,
network.loop,
network.naedgecount,
#networkOperatorSetup,
network.size,
network.vertex,
network.vertex.names,
"network.vertex.names<-",
permute.vertexIDs,
plot.network,
plot.network.default,
plotArgs.network,
print.mixingmatrix,
print.network,
print.summary.character,
print.summary.network,
prod.network,
#readAndVectorizeLine,
read.paj,
#read.paj.simplify,
"%s%",
set.edge.attribute,
set.edge.value,
set.network.attribute,
set.vertex.attribute,
summary.character,
summary.network,
sum.network,
#switchArcDirection,
"%v%",
"%v%<-",
valid.eids,
"%vattr%",
"%vattr%<-",
which.matrix.type

)

# register S3 methods

S3method('%c%',network)
S3method(add.edge, network)
S3method(add.edges, network) 
S3method(add.vertices, network)
S3method(as.network, default)
S3method(as.network, matrix)
S3method(as.network, network)
S3method(as.matrix, network)
S3method(print,mixingmatrix)
S3method(print,network)
S3method(print,summary.network)
S3method(print,summary.character)
S3method(summary,character)
S3method(summary,network)
S3method(plot,network)
S3method(plot.network,default)
S3method(is.na,network)
S3method('+',network)
S3method('-',network) 
S3method('*',network)
S3method('&',network)
S3method('|',network)
S3method('!',network)
S3method(prod,network)
S3method(sum,network)
S3method(as.edgelist,network)
S3method(as.edgelist,matrix)

S3method("[", network)
S3method("[<-", network)

# These are not 'real' S3 methods, as there is no corresponding class
# but they are dispatched by as.matrix.network and are flagged by check if not marked here
S3method(as.matrix.network,adjacency)
S3method(as.matrix.network,edgelist)
S3method(as.matrix.network,incidence)

