{"id":620,"date":"2015-04-28T01:38:59","date_gmt":"2015-04-28T07:38:59","guid":{"rendered":"http:\/\/www.harrysurden.com\/wordpress\/?p=620"},"modified":"2015-05-07T00:31:04","modified_gmt":"2015-05-07T06:31:04","slug":"visualizing-us-law-force-directed-graph","status":"publish","type":"post","link":"https:\/\/www.harrysurden.com\/wordpress\/archives\/620","title":{"rendered":"Visualizing US Law &#8211; Force Directed Graph"},"content":{"rendered":"<div style=\"font-size: 13px;\">\n<div style=\"align: center;\"><p><a href=\"http:\/\/www.harrysurden.com\/projects\/visual\/USCode_D3\/force\/Force_Directed_1.html\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-657 size-full\" src=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/circleExplode2h.gif\" alt=\"circleExploded\" width=\"308\" height=\"311\" \/><\/a><\/p>\n<\/div><p>I have created <a href=\"http:\/\/www.harrysurden.com\/projects\/visual\/USCode_D3\/force\/Force_Directed_1.html\" target=\"_blank\"> a new experimental app for visualizing and exploring U.S. Law <\/a> using a force-directed graph. \u00a0You can click on the picture above to launch it.\u00a0This force-directed visualization is more\u00a0intended to be\u00a0visually interesting rather than a full-fledged U.S. law navigation tool.<\/p><p>This is the second in a series of data visualizations of US Federal Law that I am creating using the d3 data visualization framework and javascript. \u00a0The first <a href=\"http:\/\/www.harrysurden.com\/projects\/visual\/USCode_D3\/US_Code_Tree_d3_1g.html\" target=\"_blank\">data visualization is located here.<\/a><\/p>\n<h3>Explore the Copyright Code or the Patent Code<\/h3><p>This app allows you to explore two titles of the US Code.<\/p>\n<h3 style=\"text-align: center;\">Title 17 &#8211; The Copyright Code<\/h3><p><a href=\"http:\/\/www.harrysurden.com\/projects\/visual\/USCode_D3\/force\/Force_Directed_1.html?title=17\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-627 \" src=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Circles.png\" alt=\"Copyright Circles\" width=\"336\" height=\"313\" srcset=\"https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Circles.png 693w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Circles-300x279.png 300w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Circles-620x576.png 620w\" sizes=\"(max-width: 336px) 100vw, 336px\" \/><\/a><\/p>\n<h3 style=\"text-align: center;\">Title 35 &#8211; The Patent Code<\/h3><p><a href=\"http:\/\/www.harrysurden.com\/projects\/visual\/USCode_D3\/force\/Force_Directed_1.html?title=35\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-628 \" src=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-Circles.png\" alt=\"Patent Circles\" width=\"352\" height=\"279\" srcset=\"https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-Circles.png 776w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-Circles-300x237.png 300w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-Circles-620x491.png 620w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/a><\/p>\n<h3>Hub and Spoke Representation of US Code Hierarchy<\/h3><p>The chart uses a &#8220;hub and spoke&#8221; layout to represent the hierarchy of a given Title of the U.S. Code such as Title 35. \u00a0The <strong>center<\/strong> circle represents a\u00a0&#8220;parent&#8221; portion of the code &#8211; a portion with sub-portions under it (e.g. Chapter 10) and <strong>the surrounding circles on the edge<\/strong> represent the &#8220;children&#8221; portions that belong to\u00a0that parent (Section 100, Section 101, section 103..).<\/p><p><a href=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Screen-Shot-2015-04-28-at-5.03.31-PM1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-646 size-medium\" src=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Screen-Shot-2015-04-28-at-5.03.31-PM1-300x270.png\" alt=\"Screen Shot 2015-04-28 at 5.03.31 PM\" width=\"300\" height=\"270\" srcset=\"https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Screen-Shot-2015-04-28-at-5.03.31-PM1-300x270.png 300w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Screen-Shot-2015-04-28-at-5.03.31-PM1.png 558w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p><p>You can click on an outer circle to open up the &#8220;children&#8221; parts that reside under that circle. \u00a0If a circle has &#8220;children&#8221; parts, the circle border will be a thick grey. \u00a0The selected circle will then be the new &#8220;parent&#8221;, and its &#8220;children&#8221; portions will be displayed.<\/p>\n<h3><\/h3>\n<h3>Force Directed Graph<\/h3><p>The\u00a0app uses a &#8220;<a href=\"http:\/\/en.wikipedia.org\/wiki\/Force-directed_graph_drawing\">force directed graph<\/a>&#8221; engine\u00a0to display\u00a0the titles of the U.S. Code. \u00a0Force directed graphs are often used to model\u00a0interactions between physical objects, such as molecules reacting to gravity. \u00a0Because force directed graphs such as this simulate\u00a0physical forces such as gravity, using this framework to display data means that\u00a0various parts can tend to move around somewhat randomly.<br \/>\n<!--more--><br \/>\nThus, you may notice that the layout of the different sections and subsections are not necessarily always in numerical order, or that the first section in a group of sections is located in the bottom of the circle, rather than at the top. \u00a0 This is is simply an unavoidable byproduct of using a force directed graph &#8211; the various portions sometimes drift around in unexpected places due to the force simulation. \u00a0Thus, the layout is not entirely stable, but that&#8217;s the tradeoff of using a force-directed layout.<\/p><p>Also, when there is a section with multiple sub-parts (as in Chapter 13 of the Copyright code below), the force directed layout can get a little crowded.<\/p><p><a href=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Multiple-Circles.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-642 size-medium\" src=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Multiple-Circles-300x264.png\" alt=\"Copyright Multiple Circles\" width=\"300\" height=\"264\" srcset=\"https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Multiple-Circles-300x264.png 300w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Multiple-Circles-620x545.png 620w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Copyright-Multiple-Circles.png 715w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p><p>For this reason, the force-directed graph may not be quite as useful for actually navigating\u00a0the U.S. code as the <a href=\"http:\/\/www.harrysurden.com\/projects\/visual\/USCode_D3\/US_Code_Tree_d3_1g.html\">Tree Layout visualization that I created previously<\/a>. \u00a0Rather, it is more intended as a aesthetically pleasing visualization of the U.S. code\u00a0more\u00a0than as a utilitarian law browser.<\/p><p>If you click on a circle that represents a &#8220;Part&#8221; or a &#8220;Chapter&#8221; of the title, the sub-parts expand, and the text of the law that is associated with that section appears in the grey bar on the side.<\/p><p><a href=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-102.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-633 size-large\" src=\"http:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-102-1024x621.png\" alt=\"Patent 102\" width=\"620\" height=\"376\" srcset=\"https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-102-1024x621.png 1024w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-102-300x182.png 300w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-102-620x376.png 620w, https:\/\/www.harrysurden.com\/wordpress\/wp-content\/uploads\/2015\/04\/Patent-102.png 1047w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/a><\/p><p>&nbsp;<\/p><p>&nbsp;<\/p><p>You can use the grey arrows in the upper right left hand corner to navigate back to through the hierarchy. \u00a0The up arrow brings you to the top of the hierarchy (e.g. Title 17), and the left arrow brings you up one level, to the &#8220;parent&#8221; of the currently open circle. You can also click on an open circle to bring it back to it&#8217;s parent.<\/p>\n<h3>D3, Javascript, and XML<\/h3><p>This was created using the excellent\u00a0<a href=\"http:\/\/d3js.org\/\"><strong>d3 data visualization<\/strong><\/a>\u00a0framework and javascript. \u00a0 I <a href=\"https:\/\/github.com\/mbostock\/d3\/wiki\/Force-Layout\">used Mike Bostock&#8217;s d3 force-directed layout<\/a>.<\/p><p>Visualizations like this are now possible ever since the U.S. House of representatives released the U.S. federal law in structured .xml format. \u00a0<a href=\"http:\/\/www.harrysurden.com\/wordpress\/archives\/414\">To read more about how the U.S. law became structured, you can read this blog post here.<\/a><\/p><p>I will have a follow up post explaining in more depth what I did, but in short, I wrote a parser in python to read through the US Code xml files and extract\u00a0the law\u00a0hierarchy from\u00a0the titles. \u00a0I then exported the structure in .json format.<\/p><p>More data visualizations of the law will be available in the future on <a href=\"http:\/\/www.harrysurden.com\/wordpress\/projects\">my Project Page<\/a>.<\/p>\n<h3>Caveat<\/h3><p>Please note \u2013 this is merely a beta version of this visualization. \u00a0Neither the computer code, nor the US code, have been thoroughly tested. \u00a0Please do not rely on this app for the law\u00a0as there may be errors or omissions.<\/p><p>There are a few kinks still to work out in terms of color display and layout of the circles.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I have created a new experimental app for visualizing and exploring U.S. Law using a force-directed graph. \u00a0You can click on the picture above to launch it.\u00a0This force-directed visualization is more\u00a0intended to be\u00a0visually interesting rather than a full-fledged U.S. law navigation tool.This is the second in a series of data visualizations of US Federal Law [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,4,6,12],"tags":[],"_links":{"self":[{"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/posts\/620"}],"collection":[{"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/comments?post=620"}],"version-history":[{"count":10,"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/posts\/620\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/posts\/620\/revisions\/712"}],"wp:attachment":[{"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/media?parent=620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/categories?post=620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.harrysurden.com\/wordpress\/wp-json\/wp\/v2\/tags?post=620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}