How can I combine a list of Line[]'s into one continuous Line?

Here's a graph-based solution:

gr = Graph[linelist1 /. Line[List[v__]] :> UndirectedEdge[v]];
cycle = First@FindHamiltonianCycle[gr, 1];
Graphics[{Dashing[0.01], Line[Append[cycle[[All, 1]], cycle[[-1, 2]]]]}]

Mathematica graphics


The goal here is to turn the collection of Line objects into a BoundaryMeshRegion, and then extract the boundary from that region. This is similar to user21's solution, but a bit more robust for this application.

mr = BoundaryDiscretizeGraphics[linelist2];
MeshPrimitives[mr, 2] /. Polygon[a__] :> Line[a] // 
 Graphics[{Dashing[0.01], #}] &

Mathematica graphics


linelist1 = {Line[{{0.15042300130733277`, 
      0.09918669845167598`}, {0.15124668865085406`, 0.09522452324491057`}}], 
   Line[{{0.14961629841942972`, 0.10444571885174352`}, {0.15042300130733277`, 
      0.09918669845167598`}}], 
   Line[{{0.15124668865085406`, 0.09522452324491057`}, {0.15296330904994523`, 
      0.09071834061461313`}}], 
   Line[{{0.14933067532583966`, 0.10873463230613303`}, {0.14961629841942972`, 
      0.10444571885174352`}}], 
   Line[{{0.1492065391252379`, 0.11459136282769972`}, {0.14933067532583966`, 
      0.10873463230613303`}}], 
   Line[{{0.15296330904994523`, 0.09071834061461313`}, {0.15443233429278366`, 
      0.08720754178169458`}}], 
   Line[{{0.15443233429278366`, 0.08720754178169458`}, {0.15738657618834503`, 
      0.0837116800119704`}}], 
   Line[{{0.15738657618834503`, 0.0837116800119704`}, {0.1596507357294199`, 
      0.08081800622081214`}}], 
   Line[{{0.14938185651096897`, 0.11910808435898695`}, {0.1492065391252379`, 
      0.11459136282769972`}}], 
   Line[{{0.14978835086914977`, 0.1254736636010152`}, {0.14938185651096897`, 
      0.11910808435898695`}}], 
   Line[{{0.15077460730814868`, 0.1327981842766949`}, {0.15036790182308324`, 
      0.13013455437855134`}}], 
   Line[{{0.15036790182308324`, 0.13013455437855134`}, {0.14978835086914977`, 
      0.1254736636010152`}}], 
   Line[{{0.15120855329817068`, 0.13696037633048153`}, {0.15077460730814868`, 
      0.1327981842766949`}}], 
   Line[{{0.16277911871721887`, 0.07929367135576196`}, {0.16756504304577993`, 
      0.07669208018087739`}}], 
   Line[{{0.1596507357294199`, 0.08081800622081214`}, {0.16277911871721887`, 
      0.07929367135576196`}}], 
   Line[{{0.16756504304577993`, 0.07669208018087739`}, {0.17179084853507678`, 
      0.07624695124973005`}}], 
   Line[{{0.17179084853507678`, 0.07624695124973005`}, {0.17906280098426666`, 
      0.07576450311212397`}}], 
   Line[{{0.15257273308627697`, 0.14470958676131765`}, {0.15214869088284963`, 
      0.14169046682959874`}}], 
   Line[{{0.15214869088284963`, 0.14169046682959874`}, {0.15120855329817068`, 
      0.13696037633048153`}}], 
   Line[{{0.154380363176796`, 0.15329508718925586`}, {0.15336715187177208`, 
      0.14894978414339125`}}], 
   Line[{{0.15336715187177208`, 0.14894978414339125`}, {0.15257273308627697`, 
      0.14470958676131765`}}], 
   Line[{{0.15408201484170664`, 0.17090212421388687`}, {0.154380363176796`, 
      0.15329508718925586`}}], 
   Line[{{0.17906280098426666`, 0.07576450311212397`}, {0.1846655098267246`, 
      0.07675733142107073`}}], 
   Line[{{0.1846655098267246`, 0.07675733142107073`}, {0.19526513101961043`, 
      0.07935442585321775`}}], 
   Line[{{0.19526513101961043`, 0.07935442585321775`}, {0.2025793721147758`, 
      0.08225275130107908`}}], 
   Line[{{0.2025793721147758`, 0.08225275130107908`}, {0.2174515369686099`, 
      0.0892027606755095`}}], 
   Line[{{0.15130771769953516`, 0.18272337857024754`}, {0.15175791747769907`, 
      0.1805607558081054`}}], 
   Line[{{0.15175791747769907`, 0.1805607558081054`}, {0.15408201484170664`, 
      0.17090212421388687`}}], 
   Line[{{0.14947523641765`, 0.19324727078363216`}, {0.15130771769953516`, 
      0.18272337857024754`}}], 
   Line[{{0.14922075255141615`, 0.195421957699875`}, {0.14947523641765`, 
      0.19324727078363216`}}], 
   Line[{{0.14830703464564116`, 0.20491305790082923`}, {0.14922075255141615`, 
      0.195421957699875`}}], 
   Line[{{0.14786378115799406`, 0.20890778773289803`}, {0.14791166732629607`, 
      0.20675668855532706`}}], 
   Line[{{0.1473023145442782`, 0.21917015209603855`}, {0.14786378115799406`, 
      0.20890778773289803`}}], 
   Line[{{0.14791166732629607`, 0.20675668855532706`}, {0.14830703464564116`, 
      0.20491305790082923`}}], 
   Line[{{0.1471112448868429`, 0.22098660364789832`}, {0.1473023145442782`, 
      0.21917015209603855`}}], 
   Line[{{0.14727721615276837`, 0.22307805371953965`}, {0.1471112448868429`, 
      0.22098660364789832`}}], 
   Line[{{0.1471140525731194`, 0.23582182314046962`}, {0.14709509899938097`, 
      0.23406594386910806`}}], 
   Line[{{0.14783588435291467`, 0.24801241612439603`}, {0.1471140525731194`, 
      0.23582182314046962`}}], 
   Line[{{0.14709509899938097`, 0.23406594386910806`}, {0.14727721615276837`, 
      0.22307805371953965`}}], 
   Line[{{0.2174515369686099`, 0.0892027606755095`}, {0.22682413867491788`, 
      0.09457182622878016`}}], 
   Line[{{0.23712928145996623`, 0.10232063183487138`}, {0.2468063966900775`, 
      0.10735408035037859`}}], 
   Line[{{0.23617311839755725`, 0.10167498697856284`}, {0.23712928145996623`, 
      0.10232063183487138`}}], 
   Line[{{0.22682413867491788`, 0.09457182622878016`}, {0.23617311839755725`, 
      0.10167498697856284`}}], 
   Line[{{0.2468063966900775`, 0.10735408035037859`}, {0.258487721590078`, 
      0.1157776125601875`}}], 
   Line[{{0.2708808482807588`, 0.12670886782426`}, {0.28387897498993575`, 
      0.13571165906064925`}}], 
   Line[{{0.258487721590078`, 0.1157776125601875`}, {0.2708808482807588`, 
      0.12670886782426`}}], 
   Line[{{0.28387897498993575`, 0.13571165906064925`}, {0.2978272217864588`, 
      0.14759488720466138`}}], 
   Line[{{0.1477234246451498`, 0.24947273784932386`}, {0.14783588435291467`, 
      0.24801241612439603`}}], 
   Line[{{0.1479541145674177`, 0.2511362254380753`}, {0.1477234246451498`, 
      0.24947273784932386`}}], 
   Line[{{0.1491240645508071`, 0.26387991264561694`}, {0.1479541145674177`, 
      0.2511362254380753`}}], 
   Line[{{0.14921751200149097`, 0.2652532987421324`}, {0.1491240645508071`, 
      0.26387991264561694`}}], 
   Line[{{0.14965754343046883`, 0.2667953281098005`}, {0.14921751200149097`, 
      0.2652532987421324`}}], 
   Line[{{0.151331525973231`, 0.2788746216617924`}, {0.14965754343046883`, 
      0.2667953281098005`}}], 
   Line[{{0.1513023469154561`, 0.28000225496294356`}, {0.151331525973231`, 
      0.2788746216617924`}}], 
   Line[{{0.15159808750593176`, 0.28126407977451784`}, {0.1513023469154561`, 
      0.28000225496294356`}}], 
   Line[{{0.1542183286126348`, 0.2951998224290116`}, {0.15159808750593176`, 
      0.28126407977451784`}}], 
   Line[{{0.1543844511422373`, 0.29622903636555487`}, {0.1542183286126348`, 
      0.2951998224290116`}}], 
   Line[{{0.15487515594649698`, 0.2973588777162937`}, {0.1543844511422373`, 
      0.29622903636555487`}}], 
   Line[{{0.1579674954611141`, 0.3106502784721332`}, {0.15487515594649698`, 
      0.2973588777162937`}}], 
   Line[{{0.15801884123013382`, 0.31149526756373586`}, {0.1579674954611141`, 
      0.3106502784721332`}}], 
   Line[{{0.15837231170577926`, 0.3124103567537063`}, {0.15801884123013382`, 
      0.31149526756373586`}}], 
   Line[{{0.16249412038258731`, 0.3268594270632616`}, {0.15837231170577926`, 
      0.3124103567537063`}}], 
   Line[{{0.1627258634053209`, 0.32761076950461077`}, {0.16249412038258731`, 
      0.3268594270632616`}}], 
   Line[{{0.1677923104797096`, 0.3421155216709148`}, {0.1627258634053209`, 
      0.32761076950461077`}}], 
   Line[{{0.2978272217864588`, 0.14759488720466138`}, {0.3120103725148076`, 
      0.16185946995643472`}}], 
   Line[{{0.3120103725148076`, 0.16185946995643472`}, {0.32775672771374703`, 
      0.17512244347152398`}}], 
   Line[{{0.16831982916051622`, 0.3434042241910501`}, {0.16791854046841395`, 
      0.3427532989898076`}}], 
   Line[{{0.16791854046841395`, 0.3427532989898076`}, {0.1677923104797096`, 
      0.3421155216709148`}}], 
   Line[{{0.17421155114809514`, 0.3581968200459465`}, {0.17392151465705788`, 
      0.35763372336909505`}}], 
   Line[{{0.17392151465705788`, 0.35763372336909505`}, {0.16831982916051622`, 
      0.3434042241910501`}}], 
   Line[{{0.18069422094150786`, 0.37205702305025484`}, {0.17421155114809514`, 
      0.3581968200459465`}}], 
   Line[{{0.180891236025593`, 0.37258053248480366`}, {0.18069422094150786`, 
      0.37205702305025484`}}], 
   Line[{{0.18830785455803709`, 0.38637151726676766`}, {0.180891236025593`, 
      0.37258053248480366`}}], 
   Line[{{0.18865265276787174`, 0.3868486426773692`}, {0.18830785455803709`, 
      0.38637151726676766`}}], 
   Line[{{0.19640017190085496`, 0.3994058587164615`}, {0.18865265276787174`, 
      0.3868486426773692`}}], 
   Line[{{0.19666833626667307`, 0.3999132604697406`}, {0.19640017190085496`, 
      0.3994058587164615`}}], 
   Line[{{0.20531029788487257`, 0.41211763157731013`}, {0.19666833626667307`, 
      0.3999132604697406`}}], 
   Line[{{0.20571216030393039`, 0.4126101422556851`}, {0.20531029788487257`, 
      0.41211763157731013`}}], 
   Line[{{0.2145020546238386`, 0.4233429398459504`}, {0.20571216030393039`, 
      0.4126101422556851`}}], 
   Line[{{0.21537048933945666`, 0.42440920138360355`}, {0.2148469636279404`, 
      0.42392452797297386`}}], 
   Line[{{0.2148469636279404`, 0.42392452797297386`}, {0.2145020546238386`, 
      0.4233429398459504`}}], 
   Line[{{0.224937909314532`, 0.4347906814830722`}, {0.22447106274957196`, 
      0.43419502129876153`}}], 
   Line[{{0.2255708635091629`, 0.4352755122957541`}, {0.224937909314532`, 
      0.4347906814830722`}}], 
   Line[{{0.22447106274957196`, 0.43419502129876153`}, {0.21537048933945666`, 
      0.42440920138360355`}}], 
   Line[{{0.2362387193659058`, 0.44519046171637694`}, {0.23550854177430175`, 
      0.44469711425577`}}], 
   Line[{{0.23550854177430175`, 0.44469711425577`}, {0.23493104304809412`, 
      0.4440809402390221`}}], 
   Line[{{0.23493104304809412`, 0.4440809402390221`}, {0.2255708635091629`, 
      0.4352755122957541`}}], 
   Line[{{0.2458063880151631`, 0.4529965121115738`}, {0.2362387193659058`, 
      0.44519046171637694`}}], 
   Line[{{0.24729866193283856`, 0.45414958092958785`}, {0.24648326240945`, 
      0.45363954361140574`}}], 
   Line[{{0.24648326240945`, 0.45363954361140574`}, {0.2458063880151631`, 
      0.4529965121115738`}}], 
   Line[{{0.2570213951396619`, 0.46095021578202966`}, {0.24729866193283856`, 
      0.45414958092958785`}}], 
   Line[{{0.25867545846199563`, 0.4621600936383677`}, {0.2577865151619174`, 
      0.4616258862109966`}}], 
   Line[{{0.2577865151619174`, 0.4616258862109966`}, {0.2570213951396619`, 
      0.46095021578202966`}}], 
   Line[{{0.2713565274343649`, 0.46964096460519306`}, {0.27029474445148616`, 
      0.46923832388523573`}}], 
   Line[{{0.27029474445148616`, 0.46923832388523573`}, {0.2693435427651083`, 
      0.4686736095095178`}}], 
   Line[{{0.2693435427651083`, 0.4686736095095178`}, {0.25867545846199563`, 
      0.4621600936383677`}}], 
   Line[{{0.2820834503649971`, 0.47540708814525406`}, {0.28108085796610294`, 
      0.4748070587399311`}}], 
   Line[{{0.28317996258778066`, 0.47583890202372664`}, {0.2820834503649971`, 
      0.47540708814525406`}}], 
   Line[{{0.2929264508462746`, 0.4800548651057634`}, {0.28317996258778066`, 
      0.47583890202372664`}}], 
   Line[{{0.28108085796610294`, 0.4748070587399311`}, {0.2713565274343649`, 
      0.46964096460519306`}}], 
   Line[{{0.2962869754197271`, 0.4814350589126312`}, {0.2950906392127613`, 
      0.48115832533184144`}}], 
   Line[{{0.293969971604404`, 0.48069317434650516`}, {0.2929264508462746`, 
      0.4800548651057634`}}], 
   Line[{{0.2950906392127613`, 0.48115832533184144`}, {0.293969971604404`, 
      0.48069317434650516`}}], 
   Line[{{0.3070188184813319`, 0.4856253611147443`}, {0.30588411540871324`, 
      0.4851249910683927`}}], 
   Line[{{0.3082111485742116`, 0.48593284952392213`}, {0.3070188184813319`, 
      0.4856253611147443`}}], 
   Line[{{0.30588411540871324`, 0.4851249910683927`}, {0.2962869754197271`, 
      0.4814350589126312`}}], 
   Line[{{0.3200745284695116`, 0.4896040338211999`}, {0.31889586095955874`, 
      0.4892654893053082`}}], 
   Line[{{0.3306538583299412`, 0.49210181021046007`}, {0.3200745284695116`, 
      0.4896040338211999`}}], 
   Line[{{0.31889586095955874`, 0.4892654893053082`}, {0.3082111485742116`, 
      0.48593284952392213`}}], 
   Line[{{0.32775672771374703`, 0.17512244347152398`}, {0.34339600647788815`, 
      0.19037157889533632`}}], 
   Line[{{0.34339600647788815`, 0.19037157889533632`}, {0.3584920715847559`, 
      0.20748513832003038`}}], 
   Line[{{0.3584920715847559`, 0.20748513832003038`}, {0.37529647269459104`, 
      0.22416045439778076`}}], 
   Line[{{0.391394006394934`, 0.24187639988977794`}, {0.40595760835145256`, 
      0.26052294423977673`}}], 
   Line[{{0.40595760835145256`, 0.26052294423977673`}, {0.4211937389690042`, 
      0.2783989008665915`}}], 
   Line[{{0.37529647269459104`, 0.22416045439778076`}, {0.391394006394934`, 
      0.24187639988977794`}}], 
   Line[{{0.4211937389690042`, 0.2783989008665915`}, {0.4360859857909327`, 
      0.29688362962532056`}}], 
   Line[{{0.4360859857909327`, 0.29688362962532056`}, {0.44849554349384785`, 
      0.31513488497582964`}}], 
   Line[{{0.44849554349384785`, 0.31513488497582964`}, {0.45950702525841847`, 
      0.3312352642133482`}}], 
   Line[{{0.45950702525841847`, 0.3312352642133482`}, {0.47168951000586257`, 
      0.3485013232084075`}}], 
   Line[{{0.3329811696167614`, 0.49261958674849604`}, {0.33180955627977493`, 
      0.49246904090890936`}}], 
   Line[{{0.33180955627977493`, 0.49246904090890936`}, {0.3306538583299412`, 
      0.49210181021046007`}}], 
   Line[{{0.3433488889598254`, 0.4945445748405384`}, {0.3329811696167614`, 
      0.49261958674849604`}}], 
   Line[{{0.3546249958718492`, 0.495842695338322`}, {0.3444697509923371`, 
      0.49471602188622743`}}], 
   Line[{{0.3444697509923371`, 0.49471602188622743`}, {0.3433488889598254`, 
      0.4945445748405384`}}], 
   Line[{{0.3556865540320001`, 0.4960280715277968`}, {0.3546249958718492`, 
      0.495842695338322`}}], 
   Line[{{0.3567177912758346`, 0.49597308113395`}, {0.3556865540320001`, 
      0.4960280715277968`}}], 
   Line[{{0.47168951000586257`, 0.3485013232084075`}, {0.48077950746507786`, 
      0.3644837993542871`}}], 
   Line[{{0.4860140377063631`, 0.37629909992727895`}, {0.494713514709459`, 
      0.3908117600585477`}}], 
   Line[{{0.48077950746507786`, 0.3644837993542871`}, {0.4860140377063631`, 
      0.37629909992727895`}}], 
   Line[{{0.494713514709459`, 0.3908117600585477`}, {0.5001882062215272`, 
      0.4033850666119429`}}], 
   Line[{{0.36750825194268794`, 0.4965078617110783`}, {0.36656376103364224`, 
      0.49656032955172325`}}], 
   Line[{{0.36656376103364224`, 0.49656032955172325`}, {0.3567177912758346`, 
      0.49597308113395`}}], 
   Line[{{0.37788302207581576`, 0.4962518669896069`}, {0.37703288668338875`, 
      0.4963125224987447`}}], 
   Line[{{0.3870248630651093`, 0.4952799609069687`}, {0.37788302207581576`, 
      0.4962518669896069`}}], 
   Line[{{0.37703288668338875`, 0.4963125224987447`}, {0.36750825194268794`, 
      0.4965078617110783`}}], 
   Line[{{0.3877734346697613`, 0.49519893336654924`}, {0.3870248630651093`, 
      0.4952799609069687`}}], 
   Line[{{0.39647039041779775`, 0.49345442085222035`}, {0.3877734346697613`, 
      0.49519893336654924`}}], 
   Line[{{0.397110731984245`, 0.4933399169989696`}, {0.39647039041779775`, 
      0.49345442085222035`}}], 
   Line[{{0.4053005892876792`, 0.4908254279842213`}, {0.397110731984245`, 
      0.4933399169989696`}}], 
   Line[{{0.40582676815159685`, 0.49066402514110335`}, {0.4053005892876792`, 
      0.4908254279842213`}}], 
   Line[{{0.4134479680115215`, 0.48738189051877207`}, {0.40582676815159685`, 
      0.49066402514110335`}}], 
   Line[{{0.41385501671116315`, 0.4871604717762271`}, {0.4134479680115215`, 
      0.48738189051877207`}}], 
   Line[{{0.5001882062215272`, 0.4033850666119429`}, {0.5026656466799566`, 
      0.41378366311013043`}}], 
   Line[{{0.5049910805017521`, 0.42092707055693956`}, {0.5073345408466324`, 
      0.4298919589211338`}}], 
   Line[{{0.5026656466799566`, 0.41378366311013043`}, {0.5049910805017521`, 
      0.42092707055693956`}}], 
   Line[{{0.4274391169072527`, 0.47801529681458305`}, {0.42084769258955246`, 
      0.48311400029769436`}}], 
   Line[{{0.42084769258955246`, 0.48311400029769436`}, {0.41385501671116315`, 
      0.4871604717762271`}}], 
   Line[{{0.4329580876836497`, 0.47231834863067207`}, {0.4274391169072527`, 
      0.47801529681458305`}}], 
   Line[{{0.4331675034193015`, 0.4720847717913544`}, {0.4329580876836497`, 
      0.47231834863067207`}}], 
   Line[{{0.437890159746943`, 0.46566606263920335`}, {0.4331675034193015`, 
      0.4720847717913544`}}], 
   Line[{{0.5073345408466324`, 0.4298919589211338`}, {0.507075192557166`, 
      0.43670292340445127`}}], 
   Line[{{0.507075192557166`, 0.43670292340445127`}, {0.5049458541122729`, 
      0.4449675445229827`}}], 
   Line[{{0.4776009750118953`, 0.4514099006447918`}, {0.4730868229244228`, 
      0.45077008810913194`}}], 
   Line[{{0.4730868229244228`, 0.45077008810913194`}, {0.437890159746943`, 
      0.46566606263920335`}}], 
   Line[{{0.5049458541122729`, 0.4449675445229827`}, {0.5029083407423581`, 
      0.44889688974935993`}}], 
   Line[{{0.4838758910848437`, 0.45289412540402957`}, {0.4776009750118953`, 
      0.4514099006447918`}}], 
   Line[{{0.5029083407423581`, 0.44889688974935993`}, {0.49919310111973014`, 
      0.45113398227358853`}}], 
   Line[{{0.4890646389147416`, 0.45348782067176335`}, {0.4838758910848437`, 
      0.45289412540402957`}}], 
   Line[{{0.49919310111973014`, 0.45113398227358853`}, {0.49332267538788155`, 
      0.45296691617990653`}}], 
   Line[{{0.49332267538788155`, 0.45296691617990653`}, {0.4890646389147416`, 
      0.45348782067176335`}}]};

Convert lines to points

pts = Flatten[linelist1 /. Line -> Identity, {2}][[1]];

Using ListCurvePathPlot

ListCurvePathPlot[pts,
 Frame -> True,
 Axes -> False,
 PlotStyle -> Dashed]

enter image description here

Using FindCurvePath

curve = FindCurvePath[pts];

ListLinePlot[pts[[curve[[1]]]],
 Frame -> True,
 Axes -> False,
 AspectRatio -> Automatic,
 PlotStyle -> Dashed,
 ImageSize -> 350]

enter image description here

Tags:

Graphics