[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-685755-105":59,"doc-detail-685755-en":129,"doc-similar-685755":148},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":122,"head_meta":124,"extra_data":126,"updated_unix":128},105,"en","programming-workbench-compressed-sparse-row-format-for-representing-graphs","Programming Workbench: Compressed Sparse Row Format for Representing Graphs","","Programming Workbench presents compressed sparse row (CSR) as a compact, memory-hierarchy-friendly graph representation. It frames graphs as flexible models for connectedness and ordering in computing, contrasts CSR with adjacency matrices and adjacency lists, and focuses on unweighted directed graphs while noting how undirected edges and weights can be incorporated. The discussion reviews graph representations, uses a running example, and outlines a C11 program converting an edge list into CSR, then concludes with extensions and exercises on CSR tradeoffs.",{"@graph":69,"@context":121},[70,84,104],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/programming-workbench-compressed-sparse-row-format-for-representing-graphs/685755/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":98,"encodingFormat":97,"isAccessibleForFree":99,"interactionStatistic":100},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/programming-workbench-compressed-sparse-row-format-for-representing-graphs/685755.png","ImageObject",300,407,{"name":92,"@type":93},"Aurelia","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-07",true,{"@type":101,"interactionType":102,"userInteractionCount":8},"InteractionCounter",{"@type":103},"ViewAction",{"@type":105,"mainEntity":106},"FAQPage",[107,113,117],{"name":108,"@type":109,"acceptedAnswer":110},"What problem does CSR address compared with adjacency matrices and adjacency lists?","Question",{"text":111,"@type":112},"CSR provides a more memory-efficient representation for sparse graphs, avoiding the large O(V2) storage overhead of adjacency matrices while still supporting efficient graph operations.","Answer",{"name":114,"@type":109,"acceptedAnswer":115},"How is an input graph typically provided before converting to CSR?",{"text":116,"@type":112},"The document describes an edge list format that contains “from”/“to” vertexID pairs, often requiring metadata to preserve zero-degree vertices not present in the edge list.",{"name":118,"@type":109,"acceptedAnswer":119},"What does the C11 program in the workbench article do?",{"text":120,"@type":112},"It converts an edge list representation of a graph into CSR format, producing the compact arrays needed to represent adjacency information.","https://schema.org",{"og:url":83,"og:type":123,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":125,"canonical":83},"index,follow",{"doc_id":127,"site_id":62},685755,1794017513,{"code":4,"msg":5,"data":130},{"doc_id":127,"user_id":131,"nickname":92,"user_avatar":132,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":8,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":34,"language":138,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":67,"update_tm":128,"read_time":142,"preview_page_count":8,"preview_urls":143},1099514068365,"https://ap-avatar.wpscdn.com/avatar/10000253d8d9f28188e?x-image-process=image/resize,m_fixed,w_180,h_180&k=1794309523707217728","COLUMNS   \nProgramming Workbench  \nCompressed Sparse Row Format for Representing Graphs  \nT ER EN C E K EL LY  \nTerence Kelly studied computer science at Princeton and the University of Michigan, followed by a long stint at Hewlett-Packard Laboratories . Kelly now writes code and documentation promoting persistent memory programming and other programming techniques . His past publications—some of tragicomic interest only—are listed at [http://ai.eecs. umich.edu/~tpkelly/papers/.](http://ai.eecs. umich.edu/~tpkelly/papers/.)[ ](http://ai.eecs. umich.edu/~tpkelly/papers/.)[tpkelly@eecs. umich.edu](tpkelly@eecs. umich.edu).  \nW  \nelcome to the second installment of Programming Workbench. Today’s topic is compressed sparse row (CSR) format, a compact and efficient way to represent graphs in memory. As usual, all  \nexample code is available in machine-readable form  [6] .  \nGraphs provide a generic abstraction that finds numerous applications for modeling connectedness and ordering in computing systems. Undirected graphs, for example, can represent communications links among computers; directed graphs can encode dependencies or precedence constraints in software compilation, software package installation, and job scheduling problems. Top computer science textbooks emphasize two ways of representing graphs in memory: adjacency matrices and adjacency lists  [1, 8] . Today we’ll consider other options that offer different tradeoffs and sometimes provide significant advantages. In particular we’ll see that compressed sparse row (CSR) format—a compact and memory-hierarchy-friendly graph representation—is sometimes the format of choice. Understanding CSR in detail rounds out a programmer’s education and informs the buy-or-build decisions that routinely confront practitioners.  \nWe’ll begin in the next section by reviewing ways of representing graphs, including CSR. Then we’ll walk through a working C11 program that converts an edge list representation of a graph into CSR format. Finally we’ll conclude by suggesting extensions and exercises to help better understand the tradeoffs surrounding CSR. For brevity, we’ll restrict attention to unweighted directed graphs, but we thereby lose little generality: an undirected edge can be represented by two directed edges in opposite directions, and adding edge weights to a CSR representation is easy.  \nGraph Representations  \nFigure 1(a) shows a directed graph that we’ll use as a running example. We follow the convention that vertexIDs range from 1 to V inclusive, where Vis the total number of vertices. The example graph contains V=9 vertices andE=9 directed edges. For example, there’s a directed edge from vertex 2 to vertex 1, shown as an arrow near the top of Figure 1(a). Vertices 5 and 9 have in-degree zero and out-degree zero, i. e., they have neither incoming nor outgoing edges. Zero-degree vertices arise naturally in applications; for example, they may represent software packages with no dependencies or compute jobs with no precedence constraints.  \nRather than treating zero-degree vertices as special cases, removing them and/or handling them “out of band,” we’ll take the simpler approach of representing them straightforwardly. Self edges, i. e., edges that point from a vertex to itself, do not appear in our example, but they pose no special difficulties for the graph representations discussed below. We omit self edges for brevity; they arise relatively infrequently in applications of practical interest.  \nIn many practical applications, a graph is given as a file that essentially contains an edge list of “from”/“to” vertexID pairs, possibly mummified in a more elaborate format such as XML or JSON. Figure 1(b) shows an edge list representation of our example graph. The first line in the list,“2 1,” represents the directed edge from vertex 2 to vertex 1. Zero-degree vertices, such as 5 and 9 in our example, don’t appear in an edge list, so metadata accompanying the  \n76  WINTER 2 0 2 0 VOL . 4","cbCaisFd98M2aQRd","https://ap.wps.com/l/cbCaisFd98M2aQRd","pdf",347849,"English","# Graph Representations\n## Edge List Representation\n## Adjacency Matrix Representation\n## CSR Format Overview\n## Converting Edge List to CSR\n## Tradeoffs, Extensions, and Exercises","[{\"question\":\"What problem does CSR address compared with adjacency matrices and adjacency lists?\",\"answer\":\"CSR provides a more memory-efficient representation for sparse graphs, avoiding the large O(V2) storage overhead of adjacency matrices while still supporting efficient graph operations.\"},{\"question\":\"How is an input graph typically provided before converting to CSR?\",\"answer\":\"The document describes an edge list format that contains “from”/“to” vertexID pairs, often requiring metadata to preserve zero-degree vertices not present in the edge list.\"},{\"question\":\"What does the C11 program in the workbench article do?\",\"answer\":\"It converts an edge list representation of a graph into CSR format, producing the compact arrays needed to represent adjacency information.\"}]","Programming Workbench: Compressed Sparse Row Format for Representing Graphs | PDF",18,[144],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/15b302252d5740acb2c8ddfb938036d2.webp",983,1276,{"list":149,"token":66},[150,156,162,168,175,181,188,195,202,209],{"doc_id":151,"doc_title":152,"file_type":136,"home_preview_img_url":153,"slug":154,"view_count":14,"category_name":30,"create_tm":155},685751,"Graph Algorithms - Graph Basics - Notion of Graphs","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999690613/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=pdEUDeQwvxBOUaQoKFNhHzbGSTM%3D","graph-algorithms-graph-basics-notion-of-graphs",1794017504,{"doc_id":157,"doc_title":158,"file_type":136,"home_preview_img_url":159,"slug":160,"view_count":44,"category_name":30,"create_tm":161},656373,"Automated generation of circulations within a floorplan - read online free","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975307976/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=%2BZAuMuhTcilefhEcTC6dC2bUY%2F8%3D","automated-generation-of-circulations-within-a-floorplan-read-online-free",1792968176,{"doc_id":163,"doc_title":164,"file_type":136,"home_preview_img_url":165,"slug":166,"view_count":34,"category_name":30,"create_tm":167},663136,"Graph Morphing via Orthogonal Box Drawings","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229981699662/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=U%2FNoTcSh8AB4Q1xAuyX%2B0oinD%2B4%3D","graph-morphing-via-orthogonal-box-drawings",1793225307,{"doc_id":169,"doc_title":170,"file_type":136,"home_preview_img_url":171,"slug":172,"view_count":173,"category_name":30,"create_tm":174},217203,"Markov Random Field Structure Estimator - Version 0.4.2 - Package mrfse","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229887497972/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=dNq2IFp%2BwcPzoDnu9jT3o5PT3zw%3D","markov-random-field-structure-estimator-version-042-package-mrfse",21,1788831486,{"doc_id":176,"doc_title":177,"file_type":136,"home_preview_img_url":178,"slug":179,"view_count":142,"category_name":30,"create_tm":180},122371,"Hierarchies of Reward Machines - curriculum-based hierarchical reward machines for reinforcement learning","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229836758603/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=IHit0bJ6iD8ByR3TA%2Fl78gOOifA%3D","hierarchies-of-reward-machines-curriculum-based-hierarchical-reward-machines-for-reinforcement-learning",1785810283,{"doc_id":182,"doc_title":183,"file_type":136,"home_preview_img_url":184,"slug":185,"view_count":186,"category_name":30,"create_tm":187},657698,"Using artificial intelligence to support the engineering of piping and instrumentation diagrams - modeling & prototyping","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975664220/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=LCs3wxOIDiQJ3LsY05imhIvJlg4%3D","using-artificial-intelligence-to-support-the-engineering-of-piping-and-instrumentation-diagrams-modeling-prototyping",13,1792986424,{"doc_id":189,"doc_title":190,"file_type":136,"home_preview_img_url":191,"slug":192,"view_count":193,"category_name":30,"create_tm":194},115355,"Claude AI Bible - The Complete Guide to Mastering Claude, Claude Code, Claude Cowork, MCP, AI Agents, Automation & Advanced Prompting","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229831893665/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=IsjQE1Wfge2RQ0HOBgUvCamXdK4%3D","claude-ai-bible-the-complete-guide-to-mastering-claude-claude-code-claude-cowork-mcp-ai-agents-automation-advanced-prompting",913,1785472614,{"doc_id":196,"doc_title":197,"file_type":136,"home_preview_img_url":198,"slug":199,"view_count":200,"category_name":30,"create_tm":201},185,"XNX Universal Transmitter Installation Manual (Complete Guide) [Honeywell Official]","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229693710157/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=2KP8MxIgWiA%2FGLyvfrU7Y2qcsFU%3D","xnx-universal-transmitter-installation-manual",855,1776135954,{"doc_id":203,"doc_title":204,"file_type":136,"home_preview_img_url":205,"slug":206,"view_count":207,"category_name":30,"create_tm":208},299143,"THE CANDLESTICK TRADING BIBLE - Trading Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229905832418/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=eCUky7tEkQThHnvITUZPBIFqcl0%3D","the-candlestick-trading-bible-trading-guide",804,1789767270,{"doc_id":210,"doc_title":211,"file_type":136,"home_preview_img_url":212,"slug":213,"view_count":214,"category_name":30,"create_tm":215},176,"Free Fire Proxy Server","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229693709822/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=XDehW%2FiYcuhBa%2BEzOCyDA%2B97zuM%3D","free-fire-proxy-server",565,1776135932]