Skip to content

Instantly share code, notes, and snippets.

@victoriano
Created October 28, 2024 18:46
Show Gist options
  • Save victoriano/90c6ab0e211804b6050957ad848befa0 to your computer and use it in GitHub Desktop.
Save victoriano/90c6ab0e211804b6050957ad848befa0 to your computer and use it in GitHub Desktop.
Graphext Recipe for BlueSky Social Graph
cast(ds.Username, {
"type": "category"
}) => (ds.Username)
cast(ds["Mutual Connections"], {
"type": "list[category]"
}) => (ds["Mutual Connections"])
link_rows(ds.Username, ds["Mutual Connections"], {
"weight_column": null
}) => (ds.targets_out, ds.gx_weight_out)
cluster_network(ds.targets_out,
ds.gx_weight_out) => (ds.graphext_cluster)
extract_node_pagerank(ds.targets_out,
ds.gx_weight_out) => (ds.page_rank)
configure_column_metadata(ds.page_rank,
{
"label": "Page Rank",
"description": "Find nodes whose influence extends into wider networks."
})
extract_node_degree(ds.targets_out, ds.gx_weight_out, {
"mode": "all",
"directed": false,
"loops": false
}) => (ds.degree)
configure_column_metadata(ds.degree,
{
"label": "Degree",
"description": "Find very connected nodes, popular individuals."
})
extract_node_degree(ds.targets_out, ds.gx_weight_out, {
"mode": "in",
"directed": true,
"loops": false
}) => (ds.indegree)
configure_column_metadata(ds.indegree,
{
"label": "In-degree",
"description": "Find very (in)connected nodes, popular individuals."
})
extract_node_degree(ds.targets_out, ds.gx_weight_out, {
"mode": "out",
"directed": true,
"loops": false
}) => (ds.outdegree)
configure_column_metadata(ds.outdegree,
{
"label": "Out-degree",
"description": "Find very (out)connected nodes, popular individuals."
})
extract_node_betweenness(ds.targets_out,
ds.gx_weight_out) => (ds.betweenness)
configure_column_metadata(ds.betweenness,
{
"label": "Betweenness",
"description": "Individuals who influence the flow around a system."
})
layout_network(ds.targets_out, ds.gx_weight_out, {
"gravity": 0.03,
"avoidHubs": true,
"scalingRatio": 3
}) => (ds.x, ds.y)
configure_column_visibility(ds.graphext_cluster, {
"graph": "pinned"
})
configure_column_visibility(ds.targets_out, {
"graph": "hidden",
"details": "hidden"
})
configure_column_visibility(ds.gx_weight_out, {
"graph": "hidden",
"details": "hidden"
})
configure_column_visibility(ds.x, {
"graph": "hidden",
"details": "hidden"
})
configure_column_visibility(ds.y, {
"graph": "hidden",
"details": "hidden"
})
## This function creates a new column that generates a profile link for each username in the dataset. The link format is 'https://bsky.app/profile/{$username}', where '{$username}' is replaced by the actual username from the row. The function will iterate through each row and construct the URL accordingly.
##
## Assumptions:
## - Model: gpt-4o-mini & Temperature 0.2
derive_column(ds,
{
"script": "const username = row.Username;\nreturn username ? `https://bsky.app/profile/${username}` : null;",
"type": "url"
}) => (ds.profile_link)
configure_node_url(ds.profile_link)
configure_detail_view(ds.Username, ds.profile_link)
configure_column_visibility(ds.Username, {
"graph": "hidden"
})
configure_column_visibility(ds["Relationship Type"], {
"details": "hidden",
"graph": "hidden"
})
configure_column_visibility(ds["Mutual Connections"], {
"graph": "pinned"
})
configure_columns_order(ds.graphext_cluster,
ds["Mutual Connections"],
ds.page_rank,
ds.Username,
ds["Relationship Type"],
ds.targets_out,
ds.gx_weight_out)
configure_graph_regions(ds.graphext_cluster, {
"margin": 80
})
configure_node_color(ds.graphext_cluster)
configure_columns_order(ds.Username,
ds.profile_link,
ds.graphext_cluster,
ds.degree,
ds.page_rank,
ds["Mutual Connections"],
{
"for": "dataTable"
})
configure_rows_order(ds.degree, {
"order": "descending"
})
configure_tagged_columns(ds, {
"User Information": [
"Username",
"profile_link"
],
"Network Metrics": [
"page_rank",
"degree",
"indegree",
"outdegree",
"betweenness"
],
"Graph Position": [
"x",
"y"
],
"Cluster Information": [
"graphext_cluster"
],
"Connections": [
"Relationship Type",
"Mutual Connections"
]
})
configure_node_title(ds.Username, {
"margin": 79
})
configure_node_size(ds.degree, {
"min": 0.04999999999999999,
"max": 0.19999999999999976
})
create_project(ds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment