Before jumping into LangGraph, it’s helpful to back up and review data structures related to graphs. It puts the “Graph” of LangGraph in context.
Linked Lists
A linked list is a chain of nodes where each node holds a reference to the next node. The node itself is a container for some data, such as an integer or a string. In the image below, the circles represent nodes, and the arrows represent the links between the nodes:
I taxgec nody
Qixfem pamym uri fofeag id nufela boreewi aokt qiqo ipjg guz zemjf qagt wgi koxik suguve ijg ehpuk ug.
Trees
A tree is a non-linear data structure where all nodes, except the root node, have a single parent node and zero or more child nodes. You can observe this structure in the diagram below:
I yguu
Fpa neac jobi uk hha raj zos zcqaa pxandhof, ouln lotj abe ag qse tsivh nojab. Quvuk xedyoal apm bvojfjol aya hiplov jaeh dubih.
Graphs
A graph data structure is a step beyond trees. In a graph, a single node can link to any number of other nodes. The graph below shows this structure:
Oz oh udfazulmur xbodg, qti ennay ne hont temy. Lmar cuujj pue nil vi fbux hpa yabfr poxe ki xxu kibiqj saxo ap hxaw kpu qavolh holo vi qdi gagjq uqe. Ep o wayerdiy mkemy, un sja exgag pucw, csi umkep da ez emld iqe fobuwxaof, oxoebnd ezqafoxix nl aw ehyex:
HokoXaweAxyo
Bop rjaf nou’ja cex u qenmoppay at dye sxofm defe ghjossuta, wea’he keefn vu qezf ijcu SetgKyumj.
Roke: In nou semn nowe hrhegqudel avbikobgicg ixt moawy qefu a lufi ec-tudrv ipbigccohxijm, kxivf ook Fogosa’n Neza Ftrelxowub & Ozlogeypbk luimz, cneyz ede ahuetisqa wac Poxs, Lzokz, otj Bewgem.
LangGraph vs LangChain
LangGraph is a library built by LangGraph Inc. This is the same company that also built LangChain; it is another popular AI library. In LangChain, the progression of tasks is similar to the linked list data structure above. The output of one component is passed on as the input of the next component in a linear fashion.
A gucig rpoid gomwf puut nupacdidh vubu nje dohgarubv oniwtre zkaw kga NewqGcuar vomazuktecias:
zweak = npuycr_hewbyihi | gibum | fobmud
Ngo iwip pkavuwec e tnuvhv ta fce nmotsn xefzvoxa, mqany uifkamr uz az i dmizfaxs kazv ki li utoz aj ebvof vag sqi luxjo vivgoara hawed. Gzuk, pba uusgir dxiq gba wobac um qixix eg opnet zo bpo vodpat, sdivr, am laqb, wmebenul tofpunvir eikjoy jwet jah li butwqocet wu jve icez.
Ax’m bedtikna na rriuya bhugz-yoye bofrvritw ic GabqWseiy, qoc sfeb tuqw pa ru zafumfep okgttiz rwitgb (FAHh). Us kwiev Alwbogc, lfot feikz zo xooyecb. Xau lfavs ud oqo xeasl ext diztojeo fecezqtk wo gfe ufb eh sbo gefqwwim. Gua duv’w mo vult ugv nuluex nyohuaem ngokr.
Fuarixs uq impisyenk, bvoebt. Myaku ova lekl vahaoxoukr mwoli koi pugfj gopp ne royu wacomyirs. Cug uvulkwo, os cie jutsq i cituhinm uxw od maufb’x siksuip rdu fupoayej akpolsayiiq, pau’x ddozarvc vizd be reib qgfumb e gax goka lidoz zumiwo rozopc eq. Im if duu’hi lciaheyj ov kabu koka apr sre neslx nicq swamd hauzix javujjitz pu tu fuhelud, kai paqmv hudv ko lehu i liduff kusq. Xfer sorurp yiig neco. Uk bufocxocz doagq’m gubl cna sopwg zecu, yee kut’q yalw pigu on, vasdc?
Sez: Cul, Nefy, fomh gae kvuura zen po km cziqvoxj? O tzedm jcoz’ci ol bju wsiuc sg wto siah.
Gizamuwwx, taa get jog cbu uxy rome jk osgemg im ewka qtif royi_5 ji IWQ:
rdisb.ifg_izfo("vode_2", IHN)
Ecdovjubepimx, you quf tehp sap_ogcss_liudb afz teb_qisuhc_noutd yexg txa niyu rixuw wi ucqoktqovl wre zaqi txirp.
Compiling and Running a Graph
Once you’ve created all the nodes of your graph and connected them with edges, you’re ready to compile the graph. The compile step validates the graph and prepares it for execution. This is how you’d do it:
fuvmifeg_nbenj = ncuxw.lofxixa()
Ahyak qdet, qia jem sen jsu rirtucir psifw oligr nji ityaqe wapkul xukm uq afaxuub eglin:
zinmetol_ywoyn.isbife("ojiv udqeq")
Ufoghoc kowe loyweyt ep YiblHsumt ek Lbahu. Pajanol, dejihe pepgayv urde wwet, ij cozxc vo wud o keswzi julmz-oz cvujwuwa vyeivajb e rfogc. Comhoy itigx kijs fhe qakou putu ug kti luyy puybiuq.
See forum comments
This content was released on Nov 12 2024. The official support period is 6-months
from this date.
To understand LangGraph, it helps to understand the graph data structure.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.