Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion R/mully_edge.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ getEdgeAttributes<-function(g,nodeStart,nodeDest){
stop("Invalid Arguments")
}
edgeList=as.data.frame(get.edgelist(g),stringsAsFactors = FALSE)
attributes=as.data.frame(get.edge.attribute(g),stringsAsFactors = FALSE)
attributes=as.data.frame(lapply(edge_attr(g),I),stringsAsFactors = FALSE)
edgeAttributes=cbind(edgeList,attributes)
if(missing(nodeStart) && missing(nodeDest)){
return(edgeAttributes)
Expand Down Expand Up @@ -121,6 +121,15 @@ addEdge <- function(g, nodeStart, nodeDest, attributes) {
g <- set.edge.attribute(g, key, index = idEdge, attributes[[key]])
}


# attributes of type list that were not specified in 'attributes' should be NULL instead of NA
edgeAttributes = edge_attr(g, index=idEdge)
for (key in names(edgeAttributes)) {
if (is.list(edgeAttributes[[key]]) && is.na(edgeAttributes[[key]])) {
g <- set.edge.attribute(g, key, index = idEdge, list(NULL))
}
}

#name the class
class(g) = c("mully",class(g))
return(g)
Expand Down
32 changes: 15 additions & 17 deletions R/mully_node.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ addNode <- function(g, nodeName, layerName, attributes = NA) {
}
}

# attributes of type list that were not specified in 'attributes' should be NULL instead of NA
nodeAttributes = vertex_attr(g, index=idNode)
for (key in names(nodeAttributes)) {
if (is.list(nodeAttributes[[key]]) && is.na(nodeAttributes[[key]])) {
g <- set.vertex.attribute(g, key, index = idNode, list(NULL))
}
}

#name the class
class(g) = c("mully",class(g))
return(g)
Expand Down Expand Up @@ -167,7 +175,7 @@ getNodeAttributes<-function(g,nameNode,layerByName=FALSE){
if(missing(g) || !is.mully(g)){
stop("Invalid Arguments")
}
attributes=as.data.frame(get.vertex.attribute(g),stringsAsFactors = FALSE)
attributes=as.data.frame(lapply(vertex_attr(g),I),stringsAsFactors = FALSE)
if(layerByName==TRUE){
attributes$n=g$layers$Name[attributes$n]
}
Expand All @@ -180,23 +188,13 @@ getNodeAttributes<-function(g,nameNode,layerByName=FALSE){
return(attributes[which(attributes$name==nameNode),])
}


getIDCommonDF<-function(df,df1){
#Get the common rows
common=merge.data.frame(df,df1)
#No Common Rows
if(dim(common)[1]==0){
common <- merge.data.frame(
cbind(rid=rownames(df), df),
df1
)
if (nrow(common) == 0) {
return(NULL)
}
rownb=dim(df)[1]
id=c()
for(i in 1:dim(common)[1]){
for(j in 1:rownb){
test=(df[j,]==common[i,])
if(!is.na(test) && !FALSE%in%test){
id<-append(id,rownames(df)[j])
}
}
}
return(id)
common$rid
}
4 changes: 2 additions & 2 deletions R/mully_visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ getRandomLayout <- function(g) {
g2 = g
for (i in 1:getLayersCount(g2)) {
layer = getLayerByID(g, i)
if (is.null(layer) || is.na(layer))
if (length(layer) == 0)
next

repeat {
Expand All @@ -30,7 +30,7 @@ getScaledLayout <- function(g) {
g2 = g
for (i in 1:getLayersCount(g2)) {
layer = getLayerByID(g, i)
if (is.null(layer) || is.na(layer))
if (length(layer) == 0)
next

xs = (1:length(layer)) * 8 / length(layer)
Expand Down