<commit_before>#' Triad Table
#'
#' Creates a table that contains triadID - the three nodes that make up the triad, nodeID - the character name of the node,
#' direction of the triad from the node, the valence of the triad from the node's perspective, distance of the triad from the node,
#' and nodeNum - the numeric value of the node
#'
#' @param g An igraph graph
#' @export
triad.table <- function(g) {
  if(is.null(V(g)$name)){V(g)$name <- 1:vcount(g)}
  #e.dist <- edge.distance(g)
  node_distance_holder <- shortest.paths(g, V(g))
  #e.dist.l <- list(ncol(e.dist))
  #nms <- strsplit(rownames(e.dist), "-")
  # #for(j in 1:ncol(e.dist)) {
  #   m1 <- matrix(NA, nrow = vcount(g), ncol = vcount(g))
  #   rownames(m1) <- colnames(e.dist)
  #   colnames(m1) <- colnames(e.dist)
  #
  #   for(i in 1:nrow(e.dist)) {
  #     x <- nms[[i]]
  #     m1[x[1], x[2]] <- e.dist[i, j]
  #     m1[x[2], x[1]] <- e.dist[i, j]
  #   }
  #   e.dist.l[[j]] <- m1
  # }
  e.dist.l <- edge.distance(g, lookup.mat = T)
  triads <- cliques(g, min = 3, max= 3)
  triads <- do.call('rbind', lapply(triads, function(x) { as.integer(x) }))
  dimNum <- vcount(g)
  if(is.null(triads)){stop("There are no triads in the graph")}
  triad_table <- triadTable(edgeDistance = e.dist.l, shortPaths = node_distance_holder, triads=triads, vertices=V(g), edgevalence = E(g)$valence)
  return(triad_table)
}<commit_msg>Doing some cleaning.<commit_after>#' Triad Table
#'
#' Creates a table that contains triadID - the three nodes that make up the triad, nodeID - the character name of the node,
#' direction of the triad from the node, the valence of the triad from the node's perspective, distance of the triad from the node,
#' and nodeNum - the numeric value of the node
#'
#' @param g An igraph graph
#' @export
triad.table <- function(g) {
  if(is.null(V(g)$name)){V(g)$name <- 1:vcount(g)}
  n.dist <- shortest.paths(g, V(g))
  e.dist.l <- edge.distance(g, lookup.mat = T)
  triads <- cliques(g, min = 3, max= 3)
  triads <- do.call('rbind', lapply(triads, function(x) { as.integer(x) }))
  dimNum <- vcount(g)
  if(is.null(triads)){stop("There are no triads in the graph")}
  triad_table <- triadTable(edgeDistance = e.dist.l, shortPaths = n.dist, triads=triads, vertices=V(g), edgevalence = E(g)$valence)
  return(triad_table)
}
{'fraction_non_alphanumeric': 0.1729518855656697, 'fraction_numerical': 0.007802340702210663, 'mean_word_length': 3.748971193415638, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4283808', 'n_tokens_mistral': 942, 'n_tokens_neox': 880, 'n_words': 240}