Skip to content

Instantly share code, notes, and snippets.

@beemyfriend
beemyfriend / playing_w_DAG_communites.R
Created September 6, 2018 04:41
Playing with DAG communities by adding 1 edge at different places to a base DAG
library(igraph)
library(grid)
library(gridGraphics)
#### Make a base graph ####
g <- make_tree(15) +
edges(4, 7,
8, 14,
9, 10,
15, 13)
@beemyfriend
beemyfriend / maybe_dag_community.R
Last active September 6, 2018 00:48
Using walk trap for DAG community detection
library(igraph)
g <- make_tree(10) +
edge(6, 9,
7, 10,
8, 9)
is_dag(g)
wc <- cluster_walktrap(g)
@beemyfriend
beemyfriend / favorite_bands_spotify.r
Created August 11, 2018 00:46
Playing with Spotify
install.packages('spotifyr')
library(spotifyr)
library(tidyverse)
library(httr)
Sys.setenv(SPOTIFY_CLIENT_ID = "NOT_TELLING")
Sys.setenv(SPOTIFY_CLIENT_SECRET = "NOT_TELLING")
spotify_df <- get_artist_audio_features('linkin park')
write_csv(spotify_df, 'linkin_park_spotify.csv')
@beemyfriend
beemyfriend / simple_contagion.r
Created August 8, 2018 01:43
Simple Contagion
library(igraph)
library(animation)
#===============================#
#===== Simple ==================#
#===============================#
saveGIF({
ani.options(ani.width = 800,
ani.width = 800,
@beemyfriend
beemyfriend / latticeWObstaclesTopology.R
Created July 16, 2018 01:54
Exploring graph substructures with topological obstacles (missing nodes) and node weights
library(tidyverse)
library(igraph)
####
# The pattern is to identify points to extend the structure of
# dyads and subsequent structures
# And make sure the extension isn't already part of the structure
####
@beemyfriend
beemyfriend / latticeWObstacles.R
Created July 15, 2018 04:47
Exploring graph substructures with topological obstacles (missing nodes)
####
# Dependencies
####
library(tidyverse)
library(igraph)
####
# The pattern is to identify points to extend the structure of
@beemyfriend
beemyfriend / lattice5x4.R
Created July 13, 2018 05:21
Using Tidyverse to Query Structures in
library(tidyverse)
library(igraph)
g <- make_lattice(c(5, 5))
ego(g, order = 1, mindist = 1)
head_of(g, E(g))
he <- ego(g, order = 1, mindist = 1, nodes = head_of(g, E(g)))
@beemyfriend
beemyfriend / index.html
Created November 20, 2017 06:49
Experimenting with D3 and GSAP #1
<body></body>
<script src="https://rawgit.com/gka/d3-jetpack/master/build/d3v4%2Bjetpack.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script>
////////////////////////////////////////////
// LETS CREATE THE DOM WITH D3.jetpack
////////////////////////////////////////////
var data = [{text: 'this', num: 150},
{text: 'data', num: 125},
@beemyfriend
beemyfriend / index.html
Created November 14, 2017 05:09
Playing WITH GREENSOCK!!!!!!
<head>
<style>
#hello div {
float: left
}
</style>
</head>
<body>
<div id = 'hello'></div>
@beemyfriend
beemyfriend / index.html
Last active September 2, 2017 02:30
badge
<head></head>
<body>
<svg height = '1050px' width = '1500px'>
<radialGradient id="gr-radial"
cx="50%" cy="50%" r="70%">
<!-- Animation for radius of gradient -->
<animate attributeName="r"
values="0%;175%"
dur="10s" repeatCount="indefinite" />