I got a line shapefile **tc_line** with 166 rows (line segments), and the figure below was its atttribute table:

[![enter image description here][1]][1]

and with Fiona and networkx, I also got some edges in this shapefile (stored in numpy array) ([How to get lines and nodes around the confluence point in a network system (line shapefile)?][2]):

    LINESTRING (260586.2596740723 2736302.815605165, 260586.2596740723 2736273.931404115)
    LINESTRING (260586.2596740723 2736302.815605165, 260586.2596740723 2736331.699806215)
    LINESTRING (260586.2596740723 2736302.815605165, 260615.1438751221 2736302.815605165)

I want to:

 **1. Add a column (type:float) containing 1 in the attribute table of tc_line**

 **2. In the table, find out rows (line segments), which contain edges listed above**
 
**3. Update value in the new-added column of selected rows**

But now I got stuck in stage 2 described above. I wanted to find out lines (rows in the attribute table) containing edges above by setting those edges as condition statement, but I don't know how to construct the condition statement:

    import itertools
    from shapely.geometry import Point, LineString
    import numpy

    G = nx.Graph()
    for line in fiona.open('tc_line.shp'):
        ...


I am newbie to use Fiona and networkx, and how to solve this and achieve my objectives? I am glad to receive some tips.

I am working with python 2.7.12, Fiona 1.7.0 and networkx 1.11 under Win10 64bits.


----------
**UPDATE1**

I tried to work out stage 2, and I took [intersecting two shapefiles from Python or command line][3] as reference and wrote the following script:

    import sys, os
    from shapely.geometry import mapping, shape
    import fiona
    import networkx as nx
    import itertools
    from shapely.geometry import Point, LineString
    import numpy
    
    #copy and create new shapefile
    with fiona.open('tc_line.shp', 'r') as input:
    	schema = input.schema.copy()
    	input_crs = input.crs
    	schema['properties']['pi'] = 'float'
    	with fiona.open('tc_pi.shp', 'w', 'ESRI Shapefile', schema, input_crs) as output:
    		for elem in input:
    			elem['properties']['pi']= 1
    			output.write({'properties':elem['properties'],'geometry': mapping(shape(elem['geometry']))})
    
    G = nx.Graph()
    for line in fiona.open('tc_pi.shp'):
        for seg_start, seg_end in itertools.izip(line['geometry']['coordinates'],line['geometry']['coordinates'][1:]):
            G.add_edge(seg_start, seg_end)
    
    #store edges around confluence point in numpy array
    conflu = []
    edge_node = []
    for node in G.nodes_iter():
    	if G.degree(node) > 2:
    		for edge in G.edges(node):
    			conflu.append(edge[0])
    			edge_node.append(edge[1])
    conflu_set = numpy.array(conflu)			
    edge_node_set = numpy.array(edge_node)
    edge_set = numpy.hstack((conflu_set, edge_node_set))
    print edge_set
    
    #find rows (lines) contain edges
    i = 0
    for line in fiona.open('tc_pi.shp'):
    	while i < edge_set.shape[0]:
    		print i
    		if shape(line['geometry']).contains(LineString([edge_set[i][:2], edge_set[i][2:]])):	
    			print line
    		i = i + 1

The edge_set stored coordinates of edges around confluence point:

    [[  260586.25967407  2736302.81560516   260586.25967407  2736273.93140412]
     [  260586.25967407  2736302.81560516   260586.25967407  2736331.69980621]
     [  260586.25967407  2736302.81560516   260615.14387512  2736302.81560516]
     [  252209.84136963  2744072.66568756   252238.72557068  2744072.66568756]
     [  252209.84136963  2744072.66568756   252209.84136963  2744101.54988861]
     [  252209.84136963  2744072.66568756   252209.84136963  2744043.78148651]
     [  263041.41676331  2727262.06067658   263041.41676331  2727233.17647553]
     [  263041.41676331  2727262.06067658   262983.64836121  2727319.82907868]
     [  263041.41676331  2727262.06067658   263070.30096436  2727262.06067658]
     [  270782.38264465  2733241.09029389   270753.4984436   2733269.97449494]
     [  270782.38264465  2733241.09029389   270811.2668457   2733241.09029389]
     [  270782.38264465  2733241.09029389   270782.38264465  2733212.20609284]]

and these edges were found from the same line shapefile, but the script above outputs only one record, and it was strange:

    0
    1
    2
    3
    {'geometry': {'type': 'LineString', 'coordinates': [(252238.72557067798, 2744072.6656875624), (252209.84136962818, 2744072.6656875624)]}, 'type': 'Feature', 'id': '0', 'properties': OrderedDict([(u'cat_', 73L), (u'value', 64L), (u'label', None), (u'pi', 1.0)])}
    4
    5
    6
    7
    8
    9
    10
    11

  [1]: https://i.sstatic.net/7cwrX.jpg
  [2]: http://gis.stackexchange.com/questions/215729/how-to-get-lines-and-nodes-around-the-confluence-point-in-a-network-system-line/215880#215880
  [3]: http://gis.stackexchange.com/questions/178765/intersecting-two-shapefiles-from-python-or-command-line/178787#178787