Title: | Analysis of Concept Maps and Concept Landscapes |
---|---|
Description: | Provides methods for the import/export and automated analysis of concept maps and concept landscapes (sets of concept maps). |
Authors: | Andreas Muehling |
Maintainer: | Andreas Muehling <[email protected]> |
License: | GPL-3 |
Version: | 1.1 |
Built: | 2024-12-24 06:43:31 UTC |
Source: | CRAN |
analyze.graph.measures
analyzes several graph measures. For actual implementations
see analyze.graph.measures.conceptmap
, or analyze.graph.measures.igraph
.
analyze.graph.measures(x)
analyze.graph.measures(x)
x |
A conceptmap. |
A list of several graph measures.
analyze.graph.measures
analyzes several basic graph measures of a given graph in form of a conceptmap object. All measures
are derived by the appropriate functions of igraph.
## S3 method for class 'conceptmap' analyze.graph.measures(x)
## S3 method for class 'conceptmap' analyze.graph.measures(x)
x |
A conceptmap object. |
A list with named components that contain the betweenness measure, the edge.connectivity, the diameter, the degree distribution and the communities using the Fastgreedy algorithm.
require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) analyze.graph.measures(conceptmap(g1))
require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) analyze.graph.measures(conceptmap(g1))
analyze.graph.measures.igraph
is a convenience method that can be called directly on the result of landscape
.
It works just like analyze.graph.measures.conceptmap
## S3 method for class 'igraph' analyze.graph.measures(x)
## S3 method for class 'igraph' analyze.graph.measures(x)
x |
An igraph object. |
A list with named components that contain the betweenness measure, the edge.connectivity, the diameter, the degree distribution and the communities using the Fastgreedy algorithm.
require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) analyze.graph.measures(g1)
require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) analyze.graph.measures(g1)
analyze.similarity
calculates a measure of graph similarity between two concept maps.
analyze.similarity(map1, map2)
analyze.similarity(map1, map2)
map1 |
A conceptmap object. |
map2 |
A conceptmap object. |
A value between 0 and 1 that indicated the structural similariy of the underlying graphs. The graphs need not share the same set of nodes.
The structural similarity that is calculated is described in: Goldsmith, Timothy E.; Davenport, Daniel M. (1990): Assessing Structural Similarity of Graphs. In: Roger W. Schvaneveldt (Hg.): Pathfinder associative networks. Studies in knowledge organizations. Norwood, N.J: Ablex Pub. Corp., S. 74-87.
require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) g2 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) analyze.similarity(conceptmap(g1), conceptmap(g2))
require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) g2 = set.vertex.attribute(erdos.renyi.game(15, 0.7, type="gnp"), "name", value=1:15) analyze.similarity(conceptmap(g1), conceptmap(g2))
analyze.subgraphs
analyzes the frequency of subgraph patterns given a list of concepts and a set of maps in a conceptmaps object.
analyze.subgraphs(maps, concept.list)
analyze.subgraphs(maps, concept.list)
maps |
A conceptmaps object. |
concept.list |
A list of concepts (as strings) that define the subgraphs to be analyzed. must be between 2 and 4 concepts in length. |
A list with two elements. The first is a vector that contains the absolute number of occurrences for each subgraph pattern. The second element is a list of igraph objects of the pattern themselves.
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) analyze.subgraphs(simple_cms, c("1", "2", "3"))
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) analyze.subgraphs(simple_cms, c("1", "2", "3"))
as.matrix
converts a conceptmap object into a matrix. The output can be fed back into conceptmap.matrix
.
## S3 method for class 'conceptmap' as.matrix(x, ...)
## S3 method for class 'conceptmap' as.matrix(x, ...)
x |
A conceptmap object. |
... |
- |
A matrix with 3 columns and one row for each proposition of the concept map. The 3 columns contain the start and end node of each proposition as well as the label of the edge (as character vectors).
as.matrix
converts a conceptmaps object into a matrix. The output can be fed back into conceptmaps.matrix
.
## S3 method for class 'conceptmaps' as.matrix(x, ...)
## S3 method for class 'conceptmaps' as.matrix(x, ...)
x |
A conceptmaps object. |
... |
- |
A matrix with 4 columns and one row for each proposition of one of the concept maps. The 4 columns contain an id of the map (starting from 1) and then the start and end node of each proposition as well as the label of the edge (as character vectors).
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) as.matrix(cms)
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) as.matrix(cms)
clustering
is a convenience function that implements two frequently used ways of clustering conceptmaps directly.
The first is clustering using the MBMM algorithm and the concept matrix, the second is clustering using the PAM algorithm and
the graph similarity matrix.
clustering(maps, method = c("MBMM", "PAM"), min = 1, max = 10)
clustering(maps, method = c("MBMM", "PAM"), min = 1, max = 10)
maps |
A conceptmaps object. |
method |
Either "PAM" or "MBMM", indicating which algorithm should be used. |
min |
The minimal number of components that is tested. For the PAM algorithm, 1 is not allowed. |
max |
The maximal number of components that is tested. |
The return value of either MBM.cluster
or PAM.cluster
, depending on the value of method
.
## Not run: #Assuming that there are concept maps in folder "~/maps" cms = read.folder.tgf("~/maps") clustering(cms, method="MBMM") ## End(Not run)
## Not run: #Assuming that there are concept maps in folder "~/maps" cms = read.folder.tgf("~/maps") clustering(cms, method="MBMM") ## End(Not run)
concept.vector
transforms a concept map into a numeric vector that contains for each occuring concept the number of
adjacent edges.
concept.vector(x)
concept.vector(x)
x |
A conceptmap object. |
A numeric vector. The columns are named after the concepts and sorted alphabetically.
#Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) cm = conceptmap(g1) concept.vector(cm)
#Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) cm = conceptmap(g1) concept.vector(cm)
conceptmap
creates an object that encompasses a concept maps. For actual implementations, see
conceptmap.default
, conceptmap.igraph
, or conceptmap.matrix
.
conceptmap(x, ...)
conceptmap(x, ...)
x |
- |
... |
- |
A conceptmap object.
conceptmap
creates a conceptmap object based on either an empty concept map or on (matrix) data.
## Default S3 method: conceptmap(x, ...)
## Default S3 method: conceptmap(x, ...)
x |
The concept map data. For NULL, an empty concept map is created, otherwise the object is cooerced into a matrix. |
... |
- |
A conceptmap object.
empty_cm = conceptmap(NULL)
empty_cm = conceptmap(NULL)
conceptmap
takes an existing igraph object and tries of coerce it into a conceptmap object (encompassing the igraph object).
## S3 method for class 'igraph' conceptmap(x, strip = TRUE, ...)
## S3 method for class 'igraph' conceptmap(x, strip = TRUE, ...)
x |
An igraph object. It must have an attribute called "name" for both vertices and edges. Additional attributes are preserved for graph, vertices and edges. |
strip |
If TRUE, nodes without adjacent edges are removed from the graph / concept map. |
... |
- |
A conceptmap object.
#Create conceptmap from a complete graph with 5 nodes require("igraph") graph = graph.full(5) graph = set.vertex.attribute(graph, "name", value=1:5) simple_cm = conceptmap(graph)
#Create conceptmap from a complete graph with 5 nodes require("igraph") graph = graph.full(5) graph = set.vertex.attribute(graph, "name", value=1:5) simple_cm = conceptmap(graph)
conceptmap
creates a conceptmap object from a given matrix of a particular format (see below).
## S3 method for class 'matrix' conceptmap(x, ...)
## S3 method for class 'matrix' conceptmap(x, ...)
x |
A matrix of character vectors with at least 3 columns. Each row is of the form:
start, end, label, (edge attribute 1), ..., (edge attribute m).
Each such row will be interpreted as a directed edge from concept "start" to concept "end" with the name "label" and (optional) m additional edge attributes.
The colum names of |
... |
- |
A conceptmap object.
data = rbind(cbind("Object", "Class", "is instance of"), cbind("Class", "Attribute", "has")) cm = conceptmap(data)
data = rbind(cbind("Object", "Class", "is instance of"), cbind("Class", "Attribute", "has")) cm = conceptmap(data)
conceptmaps
creates an object that encompasses a set of concept maps. For actual implementations, see
conceptmaps.default
, conceptmaps.list
, conceptmaps.matrix
.
conceptmaps(x, ...)
conceptmaps(x, ...)
x |
- |
... |
- |
A conceptmaps object.
conceptmaps
creates a conceptmaps object based on either an empty set of concept map or on a list of concept maps.
## Default S3 method: conceptmaps(x, ...)
## Default S3 method: conceptmaps(x, ...)
x |
The set of concept maps. For NULL, an empty set of concept maps is created, otherwise the object is cooerced into a list. |
... |
- |
A conceptmaps object.
empty_cms = conceptmaps(NULL)
empty_cms = conceptmaps(NULL)
conceptmaps
creates a conceptmaps object from a list of conceptmap objects.
## S3 method for class 'list' conceptmaps(x, filter = T, ...)
## S3 method for class 'list' conceptmaps(x, filter = T, ...)
x |
A list of conceptmap objects. |
filter |
If TRUE, empty concept maps (i.e. concept maps without any proposition) are not contained in the resulting set. |
... |
- |
A conceptmaps object.
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3)))
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3)))
conceptmaps
creates a conceptmaps object from a set of concept maps represented as a matrix.
## S3 method for class 'matrix' conceptmaps(x, filter = T, ...)
## S3 method for class 'matrix' conceptmaps(x, filter = T, ...)
x |
A matrix that represents a set of concept maps. The first colum is taken to identify the map, i.e.
for each value occuring in the first column, the rows with identical values are extracted and |
filter |
If TRUE, empty concept maps (i.e. concept maps without any proposition) are not contained in the resulting set. |
... |
- |
A conceptmaps object.
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data)
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data)
edge.vector
transforms a concept map into a numeric vector that contains for each occuring pair of concepts whether or not
this pair is connected by a proposition in the concept map.
edge.vector(x)
edge.vector(x)
x |
A conceptmap object. |
A numeric vector. The columns are named after the concept-pairs which are sorted alphabetically.
#Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) cm = conceptmap(g1) edge.vector(cm)
#Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) cm = conceptmap(g1) edge.vector(cm)
get.unified.concepts
identifies the common superset of concepts that is used by the maps of a conceptmaps object.
get.unified.concepts(maps)
get.unified.concepts(maps)
maps |
A conceptmaps object. |
A vector of strings of each concepts that appears in at least one of the maps of maps
.
Hopkins.index
calculates the Hopkins index that can be used as an indicator of the non-randomness of data prior to clustering.
Hopkins.index(data)
Hopkins.index(data)
data |
A numeric matrix. |
The Hopkins index as a numeric value
The index is described in, e.g.: Han, Jiawei; Kamber, Micheline (2010): Data mining. Concepts and techniques. 2nd ed., Amsterdam: Elsevier/Morgan Kaufmann (The Morgan Kaufmann series in data management systems).
## Not run: #Random data generation, 10 dimensions, 500 observations, 2 clusters, #Multivariate-Bernoulli distributed require("gtools") data = c() p = 0.0 for (i in 1:2) { temp = c() for (j in 1:10) temp = cbind(temp, rbinom(250, 1, p+(i-1)*0.5+(0.025*i)*j)) data=rbind(data, temp) } data = data[permute(1:500),] Hopkins.index(data) ## End(Not run)
## Not run: #Random data generation, 10 dimensions, 500 observations, 2 clusters, #Multivariate-Bernoulli distributed require("gtools") data = c() p = 0.0 for (i in 1:2) { temp = c() for (j in 1:10) temp = cbind(temp, rbinom(250, 1, p+(i-1)*0.5+(0.025*i)*j)) data=rbind(data, temp) } data = data[permute(1:500),] Hopkins.index(data) ## End(Not run)
landscape
transforms a set of concept maps into a concept landscape using one of several possible methods.
Depending on the value of result
and accumulation or amalgamation is performed on the concept map data. The amalgamation
forms a weighted graph based on the unified set of concepts. An accumulation transforms each concept map into a vector and
returns a matrix of these vectors. Using FUN
the process of transformation can be influenced in both cases.
landscape(maps, result = c("graph", "matrix"), mode, FUN = NULL)
landscape(maps, result = c("graph", "matrix"), mode, FUN = NULL)
maps |
A conceptmaps object. |
result |
Either "graph" or "matrix" defines the return type and the method of aggregation. An amalgamation results in a weighted graph and an accumulation results a matrix. |
mode |
If |
FUN |
If |
Depending on result
either an igraph object or a numeric matrix.
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) landscape(cms, result="graph", mode="undirected") landscape(cms, result="matrix", mode="concept.vector")
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) landscape(cms, result="graph", mode="undirected") landscape(cms, result="matrix", mode="concept.vector")
MBM.cluster
calculates a model based clustering using multivariate Bernoulli-mixtures as probabilistic model of the data.
The quality of the clustering is judged using the AIC criterion.
MBM.cluster(data, min = 1, max = 10)
MBM.cluster(data, min = 1, max = 10)
data |
A numeric matrix. |
min |
The minimal number of components that is tested. |
max |
The maximal number of components that is tested. |
A list with 3 elements. The first element is the minimal AIC value for each tested number of components.
The second element is a vector of all AIC values. The third is the actual clustering as returned by the EM algorithm using
the optimal number of components according to AIC. The element is again a list that contains the mixture coefficients, the actual
parameters of the mutlivariate Benroulli distributions, the probability matrix of each observation (i.e. row if data
)
and component and the number of iterations that the EM algorithm needed to converge.
#Random data generation, 100 observations, 5 dimensions, dependencies within the dimensions data = cbind(round(runif(100)), round(runif(100)), round(runif(100))) data = cbind(data, data[,2], 1-data[,3]) #Noisy data: s = round(runif(2, 1, 100)) data[s, c(4,5)] = 1 - data[s, c(4,5)] #MBMM Clustering res = MBM.cluster(data, 1,8)
#Random data generation, 100 observations, 5 dimensions, dependencies within the dimensions data = cbind(round(runif(100)), round(runif(100)), round(runif(100))) data = cbind(data, data[,2], 1-data[,3]) #Noisy data: s = round(runif(2, 1, 100)) data[s, c(4,5)] = 1 - data[s, c(4,5)] #MBMM Clustering res = MBM.cluster(data, 1,8)
merge
takes two conceptsmaps objects and merges the underyling sets of conceptmaps.
## S3 method for class 'conceptmaps' merge(x, y, ...)
## S3 method for class 'conceptmaps' merge(x, y, ...)
x |
A conceptmaps object. |
y |
A conceptmaps object. |
... |
- |
A conceptmaps object that consist of the maps of x
and y
.
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cm1 = conceptmaps(data[1:2,]) cm2 = conceptmaps(data[3:5,]) merge(cm1, cm2)
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cm1 = conceptmaps(data[1:2,]) cm2 = conceptmaps(data[3:5,]) merge(cm1, cm2)
modify.concepts
modifies the list of concept of a concept map or of all maps of a set.
For actual implementations see modify.concepts.conceptmap
, or modify.concepts.conceptmaps
.
modify.concepts(x, concept.list, ...)
modify.concepts(x, concept.list, ...)
x |
A conceptmap or conceptmaps object. |
concept.list |
A list of concepts. |
... |
- |
A conceptmaps or conceptmap object.
modify.concepts
modifes the list of concepts according to a given list.
This includes removing concepts and adjacent propositions as well as adding (unconnected) concepts.
## S3 method for class 'conceptmap' modify.concepts(x, concept.list, ...)
## S3 method for class 'conceptmap' modify.concepts(x, concept.list, ...)
x |
A conceptmap object. |
concept.list |
A vector of strings that contains the list of concepts. |
... |
- |
A conceptmap object that encompasses exactly the concepts of concept.list
.
Concepts not originally in map
are added as isolated nodes/concepts. Concepts of map
that are not in concept.list
are removed together with their adjacent propositions.
data = rbind(cbind("Object", "Class", "is instance of"), cbind("Class", "Attribute", "has")) cm = conceptmap(data) modify.concepts(cm, c("Object", "Class", "Method"))
data = rbind(cbind("Object", "Class", "is instance of"), cbind("Class", "Attribute", "has")) cm = conceptmap(data) modify.concepts(cm, c("Object", "Class", "Method"))
modify.concepts
calls modify.concepts.conceptmap
for each conceptmap object of a conceptmaps object.
Therefore, all concept maps will share the same set of concepts afterwards.
## S3 method for class 'conceptmaps' modify.concepts(x, concept.list, filter = F, ...)
## S3 method for class 'conceptmaps' modify.concepts(x, concept.list, filter = F, ...)
x |
A conceptmaps object. |
concept.list |
A vector of strings that contains the list of concepts. |
filter |
If TRUE, concept maps that contain no propositions after the concept modification are removed from the result. |
... |
- |
A conceptmaps object that contains (possibly a subset of) the maps of maps
in which every map contains the concepts of concept.list
.
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) modify.concepts(cms, c("Object", "Class"), filter=TRUE)
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) modify.concepts(cms, c("Object", "Class"), filter=TRUE)
PAM.cluster
calculates a clustering using the PAM algorithm (k-medoids). The quality of the clustering is judged using the
G1 index.
PAM.cluster(data, min = 2, max = 10, metric = "manhattan")
PAM.cluster(data, min = 2, max = 10, metric = "manhattan")
data |
A numeric matrix. |
min |
The minimal number of components that is tested. Must be at least 2. |
max |
The maximal number of components that is tested. |
metric |
If empty, data will be treated as a distance matrix. Otherwise, the value will be passed to the call of |
A list with 3 elements. The first element contains the optimal number of components according to the G1 index.
The second element contains a vector of the G1 values. The thrid element contains the clustering itself,
i.e. the return value of PAM
.
## Not run: #Random data generation, 10 dimensions, 500 observations, 2 clusters require("gtools") data = c() p = 0.0 for (i in 1:2) { temp = c() for (j in 1:10) temp = cbind(temp, rbinom(250, 1, p+(i-1)*0.5+(0.025*i)*j)) data=rbind(data, temp) } data = data[permute(1:500),] PAM.cluster(data) ## End(Not run)
## Not run: #Random data generation, 10 dimensions, 500 observations, 2 clusters require("gtools") data = c() p = 0.0 for (i in 1:2) { temp = c() for (j in 1:10) temp = cbind(temp, rbinom(250, 1, p+(i-1)*0.5+(0.025*i)*j)) data=rbind(data, temp) } data = data[permute(1:500),] PAM.cluster(data) ## End(Not run)
pathfinder
creates Pathfinder network. For more information and actual implementations
see pathfinder.matrix
, pathfinder.conceptmaps
, or pathfinder.igraph
.
pathfinder(data, q, r, ...)
pathfinder(data, q, r, ...)
data |
The input data. |
q |
The q parameter of the Pathfinder algorithm. |
r |
The r parameter of the Pathfinder algorithm. |
... |
- |
The Pathfinder network of the input data.
pathfinder
creates the Pathfinder network from a given set of conceptmaps. The conecpts of each concept map are
unified, then the concept maps are transformed into a weight matrix and pathfinder.matrix
is called on the data.
## S3 method for class 'conceptmaps' pathfinder(data, q = 2, r = 1, threshold = 0, directed = F, prune.edges = F, return.cm = F, filename = "", ...)
## S3 method for class 'conceptmaps' pathfinder(data, q = 2, r = 1, threshold = 0, directed = F, prune.edges = F, return.cm = F, filename = "", ...)
data |
A conceptmaps object. |
q |
The parameter q used in the Pathfinder algorithm. The resulting graph will be q-triangular. |
r |
The parameter r used in the Pathfinder algorithm for the r-metric. |
threshold |
A numeric value used for pruning the graph before the Pathfinder algorithm. The pruning works in conjunction with
the value of |
directed |
if TRUE, the direction of the edges will be kept and the resulting Pathfinder network will be directed as well. |
prune.edges |
If TRUE, each entry of the weight matrix that is lower than |
return.cm |
If TRUE, a conceptmap object will be returned. Otherwise, an igrpah object will be returned. |
filename |
Optional. If specified, the resulting Pathfinder network will be stored in TGF format in the given file. |
... |
- |
Depending on return.cm
either an igraph object or a conceptmap object that represents the Pathfinder network.
If an igraph object is returned, the graph will be weighted.
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) #Create Pathfinder network from data and return a conceptmap object cm = pathfinder(simple_cms, q=1, return.cm=TRUE)
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) #Create Pathfinder network from data and return a conceptmap object cm = pathfinder(simple_cms, q=1, return.cm=TRUE)
pathfinder
creates the Pathfinder network from a weighted graph based on pathfinder.matrix
. It is a convenience method that can be called
on the result of a call to landscape
## S3 method for class 'igraph' pathfinder(data, q = 2, r = 1, threshold = 0, prune.edges = F, filename = "", ...)
## S3 method for class 'igraph' pathfinder(data, q = 2, r = 1, threshold = 0, prune.edges = F, filename = "", ...)
data |
An igraph object. |
q |
The parameter q used in the Pathfinder algorithm. The resulting graph will be q-triangular. |
r |
The parameter r used in the Pathfinder algorithm for the r-metric. |
threshold |
A numeric value used for pruning the graph before the Pathfinder algorithm. The pruning works in conjunction with
the value of |
prune.edges |
If TRUE, each entry of the weight matrix that is lower than |
filename |
Optional. If specified, the resulting Pathfinder network will be stored in TGF format in the given file. |
... |
- |
An igraph object that represents the Pathfinder network as a weighted graph.
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) pathfinder(landscape(simple_cms, result="graph", mode="undirected"))
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) pathfinder(landscape(simple_cms, result="graph", mode="undirected"))
pathfinder
creates the Pathfinder network from a given weight matrix.
## S3 method for class 'matrix' pathfinder(data, q, r, ...)
## S3 method for class 'matrix' pathfinder(data, q, r, ...)
data |
A non-negative weight matrix of a graph that can be either directed or undirected. |
q |
The parameter q used in the Pathfinder algorithm. The resulting graph will be q-triangular. |
r |
The parameter r used in the Pathfinder algorithm for the r-metric. |
... |
- |
A numeric weight matrix that represented the Pathfinder graph of the input graph.
The Pathfinder algorithm is implemented based on the description in: Dearholt, Donald W.; Schvaneveldt, Roger W. (1990): Properties of Pathfinder Netowrks. In: Roger W. Schvaneveldt (Hg.): Pathfinder associative networks. Studies in knowledge organizations. Norwood, N.J: Ablex Pub. Corp., S. 1-30.
#Manually create a weighted graph data = matrix(data = 0, nrow = 6, ncol=6) colnames(data) <- c("Object", "Class", "Method", "Attribute", "Visibility", "Algorithm") rownames(data) <- c("Object", "Class", "Method", "Attribute", "Visibility", "Algorithm") data["Object", "Class"] = 3 data["Object", "Method"] = 3 data["Object", "Attribute"] = 10 data["Object", "Visibility"] = Inf data["Object", "Algorithm"] = 9 data["Class", "Method"] = 7 data["Class", "Attribute"] = 6 data["Class", "Visibility"] = 8 data["Class", "Algorithm"] = 10 data["Method", "Attribute"] = 4 data["Method", "Visibility"] = 9 data["Method", "Algorithm"] = 3 data["Attribute", "Visibility"] = 5 data["Attribute", "Algorithm"] = 10 data["Visibility", "Algorithm"] = Inf data = data + t(data) #Run the Pathfinder algorithm with several different parameters pathfinder(data, 5, 1) pathfinder(data, 2, 1) pathfinder(data, 5,Inf) pathfinder(data, 2, Inf)
#Manually create a weighted graph data = matrix(data = 0, nrow = 6, ncol=6) colnames(data) <- c("Object", "Class", "Method", "Attribute", "Visibility", "Algorithm") rownames(data) <- c("Object", "Class", "Method", "Attribute", "Visibility", "Algorithm") data["Object", "Class"] = 3 data["Object", "Method"] = 3 data["Object", "Attribute"] = 10 data["Object", "Visibility"] = Inf data["Object", "Algorithm"] = 9 data["Class", "Method"] = 7 data["Class", "Attribute"] = 6 data["Class", "Visibility"] = 8 data["Class", "Algorithm"] = 10 data["Method", "Attribute"] = 4 data["Method", "Visibility"] = 9 data["Method", "Algorithm"] = 3 data["Attribute", "Visibility"] = 5 data["Attribute", "Algorithm"] = 10 data["Visibility", "Algorithm"] = Inf data = data + t(data) #Run the Pathfinder algorithm with several different parameters pathfinder(data, 5, 1) pathfinder(data, 2, 1) pathfinder(data, 5,Inf) pathfinder(data, 2, Inf)
plot
plots a concept map. Includes finding a good layout based on communities and a circular layout.
Is especially suited for plotting larger concept maps, in particular amalgamations.
## S3 method for class 'conceptmap' plot(x, edge.labels = T, max.label.len = 25, scale = 1, layout = NULL, ...)
## S3 method for class 'conceptmap' plot(x, edge.labels = T, max.label.len = 25, scale = 1, layout = NULL, ...)
x |
A conceptmap object. |
edge.labels |
If TRUE, the labels of edges will be plotted as well. |
max.label.len |
The maximal length of labels (in characters) that are plotted completely. Longer labels will be shortend by "...". |
scale |
Overall scaling factor that is applied to the plot. |
layout |
If not NULL, must either be one of "fruchterman.reingold", "kamada.kawai", "spring" or "reingold.tilford" or a numeric matrix. If it is a string, the corresponding layouting algorithm of the igraph package will be called. If it is a numeric matrix, it must contain a row for each concept and two columns that determine the x and y coordinates of this concept. Then this layout will be used directly. |
... |
- |
-
#Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) E(g1)$name <- rep("", length(E(g1))) plot(conceptmap(g1), edge.labels=FALSE, layout="kamada.kawai")
#Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) E(g1)$name <- rep("", length(E(g1))) plot(conceptmap(g1), edge.labels=FALSE, layout="kamada.kawai")
plot
plots a set of concept maps. The layout is determined based on the union of all concept maps, then each
map is individually plotted using this fixed layout. Is escpecially useful for visualizing horizontal landscapes.
## S3 method for class 'conceptmaps' plot(x, edge.labels = T, max.label.len = 25, scale = 1, layout = NULL, ...)
## S3 method for class 'conceptmaps' plot(x, edge.labels = T, max.label.len = 25, scale = 1, layout = NULL, ...)
x |
A conceptmaps object. |
edge.labels |
If TRUE, the labels of edges will be plotted as well. |
max.label.len |
The maximal length of labels (in characters) that are plotted completely. Longer labels will be shortend by "...". |
scale |
Overall scaling factor that is applied to the plot. |
layout |
If not NULL, must be one of "fruchterman.reingold", "kamada.kawai", "spring" or "reingold.tilford". The corresponding layouting algorithm of the igraph package will be called. If it is NULL, the layouting based on communities and a circular layout will be used. |
... |
- |
-
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) E(g1)$name <- rep("", length(E(g1))) E(g2)$name <- rep("", length(E(g2))) E(g3)$name <- rep("", length(E(g3))) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) plot(simple_cms, layout="spring")
#Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) E(g1)$name <- rep("", length(E(g1))) E(g2)$name <- rep("", length(E(g2))) E(g3)$name <- rep("", length(E(g3))) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) plot(simple_cms, layout="spring")
print
displays basic information. For plotting, see plot.conceptmap
## S3 method for class 'conceptmap' print(x, ...)
## S3 method for class 'conceptmap' print(x, ...)
x |
A conceptmap object. |
... |
- |
-
print
displays basic information. For plotting, see plot.conceptmaps
## S3 method for class 'conceptmaps' print(x, ...)
## S3 method for class 'conceptmaps' print(x, ...)
x |
A conceptmaps object. |
... |
- |
-
read.folder.tgf
reads several TGF files and imports them as a conceptmaps object.
read.folder.tgf(folder, strip = TRUE)
read.folder.tgf(folder, strip = TRUE)
folder |
The path of a folder in which every TGF file is read. |
strip |
Passed to the call of |
A list consisting of a conceptmaps object and the list of filenames (in the same order as the maps in the conceptmaps object).
## Not run: #Assuming that the data is in the folder "~/cmaps" cm = read.folder.tgf("~/cmaps") ## End(Not run)
## Not run: #Assuming that the data is in the folder "~/cmaps" cm = read.folder.tgf("~/cmaps") ## End(Not run)
read.folder.yEd
reads several graphML files that were created by yEd and imports them as a conceptmaps object.
read.folder.yEd(folder, strip = TRUE)
read.folder.yEd(folder, strip = TRUE)
folder |
The path of a folder in which every graphML file is read. |
strip |
Passed to the call of |
A list consisting of a conceptmaps object and the list of filenames (in the same order as the maps in the conceptmaps object).
## Not run: #Assuming that the data is in the folder "~/cmaps" cm = read.folder.yEd("~/cmaps") ## End(Not run)
## Not run: #Assuming that the data is in the folder "~/cmaps" cm = read.folder.yEd("~/cmaps") ## End(Not run)
read.tgf
reads a TGF file and imports the graph as a conceptmap object.
read.tgf(file, strip = TRUE)
read.tgf(file, strip = TRUE)
file |
The filename and path that should be read. |
strip |
Passed to the call of |
A conceptmap object.
## Not run: #Assuming that the data is in "~/cmap.tgf" cm = read.tgf("~/cmap.tgf") ## End(Not run)
## Not run: #Assuming that the data is in "~/cmap.tgf" cm = read.tgf("~/cmap.tgf") ## End(Not run)
read.yEd
reads a graphML file that was created by yEd and imports the graph as a conceptmap object.
read.yEd(file, strip = TRUE)
read.yEd(file, strip = TRUE)
file |
The filename and path that should be read. |
strip |
Passed to the call of |
A conceptmap object.
## Not run: #Assuming that the data is in "~/cmap.graphml" cm = read.yEd("~/cmap.graphml") ## End(Not run)
## Not run: #Assuming that the data is in "~/cmap.graphml" cm = read.yEd("~/cmap.graphml") ## End(Not run)
splice
selects a subset of a set of concept maps and returns them as a new conceptmaps object.
splice(maps, keep)
splice(maps, keep)
maps |
A conceptmaps object. |
keep |
A numeric vector containing the indices of the maps in |
A conceptmaps object that consist of the maps with indiced of maps
.
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) splice(cms, c(1,3))
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) splice(cms, c(1,3))
summary
returns basic information about a conceptmap object
## S3 method for class 'conceptmap' summary(object, ...)
## S3 method for class 'conceptmap' summary(object, ...)
object |
A conceptmap object. |
... |
- |
A list with the number of concepts, edges and components of the concept map.
summary
returns basic information about a conceptmaps object
## S3 method for class 'conceptmaps' summary(object, ...)
## S3 method for class 'conceptmaps' summary(object, ...)
object |
A conceptmaps object. |
... |
- |
A matrix with one column for each concept map in the set and the number of concepts, edges, and components of this map respectively in 3 rows.
unify.concepts
first calls get.unified.concepts
on the maps of a conceptmaps object and then calls
modify.concepts.conceptmaps
on each of the constituent maps. Afterwards, therefore, each map of the conceptmaps object will
share the same common superset of concepts.
unify.concepts(maps)
unify.concepts(maps)
maps |
A conceptmaps object. |
A conceptmaps object in of the same map of maps
, in which every map shares the same concepts.
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) unify.concepts(cms)
data = rbind( cbind("1", "Object", "Class", "is instance of"), cbind("1", "Object", "Attribute", "has"), cbind("2", "Class", "Attribute", "possesses"), cbind("2", "Attribute", "Data-type", "has"), cbind("3", "Object", "Class", "is instance of") ) cms = conceptmaps(data) unify.concepts(cms)
write.tgf
stores the graph underlying a conceptmap object into a file using the "Trivial Grpah Format" (TGF).
write.tgf(map, file, translation = NULL)
write.tgf(map, file, translation = NULL)
map |
A conceptmap object. |
file |
The location including filename where the file should be stored. |
translation |
If not NULL, a vector of strings of equal length as the number of concepts used in the concept map. Then, the names given in this vector will be used in the file instead of the original concepts. Can be used, for example, to translate the concepts into a different language for export. |
-
## Not run: #Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) write.tgf(conceptmap(g1), "~/cmap.tgf", translation = c("Node_1", "Node_2", "Node_3", "Node_4", "Node_5")) ## End(Not run)
## Not run: #Create concept map from a random graph require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) write.tgf(conceptmap(g1), "~/cmap.tgf", translation = c("Node_1", "Node_2", "Node_3", "Node_4", "Node_5")) ## End(Not run)
write.tgf.folder
stores the graphs underlying the maps of a conceptmaps object into a folder using the "Trivial Grpah Format" (TGF).
The function calls write.tgf
for each of the maps of a conceptmaps object. The files will be named "1.tgf", "2.tgf" and so on.
write.tgf.folder(maps, folder, translation = NULL)
write.tgf.folder(maps, folder, translation = NULL)
maps |
A conceptmap object. |
folder |
The location where the files should be stored. The folder is created, if necessary. |
translation |
See |
-
## Not run: #Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) write.tgf.folder(simple_cms, "~/cmaps") ## End(Not run)
## Not run: #Create concept maps from three random graphs require("igraph") g1 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g2 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) g3 = set.vertex.attribute(erdos.renyi.game(5, 0.7, type="gnp"), "name", value=1:5) #Create conceptmaps object from three conceptmap objects simple_cms = conceptmaps(list(conceptmap(g1), conceptmap(g2), conceptmap(g3))) write.tgf.folder(simple_cms, "~/cmaps") ## End(Not run)